{"record":{"id":"fdd28c2b900cc7e6","repo":"OpenFeign/feign","slug":"soap-only-supports-encoding-raw-types-found-s-fdd28c","errorCode":null,"errorMessage":"SOAP only supports encoding raw types. Found %s","messagePattern":"SOAP only supports encoding raw types\\. Found (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"soap/src/main/java/feign/soap/SOAPEncoder.java","lineNumber":116,"sourceCode":"    this.jaxbContextFactory = builder.jaxbContextFactory;\n    this.writeXmlDeclaration = builder.writeXmlDeclaration;\n    this.charsetEncoding = builder.charsetEncoding;\n    this.soapProtocol = builder.soapProtocol;\n    this.formattedOutput = builder.formattedOutput;\n  }\n\n  public SOAPEncoder(JAXBContextFactory jaxbContextFactory) {\n    this.jaxbContextFactory = jaxbContextFactory;\n    this.writeXmlDeclaration = true;\n    this.formattedOutput = false;\n    this.charsetEncoding = StandardCharsets.UTF_8;\n    this.soapProtocol = DEFAULT_SOAP_PROTOCOL;\n  }\n\n  @Override\n  public void encode(Object object, Type bodyType, RequestTemplate template) {\n    if (!(bodyType instanceof Class)) {\n      throw new UnsupportedOperationException(\n          \"SOAP only supports encoding raw types. Found \" + bodyType);\n    }\n    try {\n      Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();\n      Marshaller marshaller = jaxbContextFactory.createMarshaller((Class<?>) bodyType);\n      marshaller.marshal(object, document);\n      SOAPMessage soapMessage = MessageFactory.newInstance(soapProtocol).createMessage();\n      soapMessage.setProperty(\n          SOAPMessage.WRITE_XML_DECLARATION, Boolean.toString(writeXmlDeclaration));\n      soapMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, charsetEncoding.displayName());\n      soapMessage.getSOAPBody().addDocument(document);\n\n      soapMessage = modifySOAPMessage(soapMessage);\n\n      ByteArrayOutputStream bos = new ByteArrayOutputStream();\n      if (formattedOutput) {\n        Transformer t = TransformerFactory.newInstance().newTransformer();\n        t.setOutputProperty(OutputKeys.INDENT, \"yes\");","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/soap/src/main/java/feign/soap/SOAPEncoder.java#L98-L134","documentation":"The javax-based SOAPEncoder.encode() requires the body type to be a raw Class for JAXB marshalling (jaxbContextFactory.createMarshaller((Class<?>) bodyType)); any other Type throws UnsupportedOperationException before serialization starts. Identical behavior to the jakarta variant, just in the javax module.","triggerScenarios":"Invoking a Feign method whose request body parameter type is a generic type variable, wildcard, or otherwise not a concrete Class, causing encode() to reject the bodyType.","commonSituations":"Generic client interfaces parameterized over request DTOs; passing Map/list wrappers and expecting generic marshalling support.","solutions":["Use a concrete request class as the parameter type.","Split generic interfaces into concrete per-type interfaces.","Pre-resolve generics in a custom Encoder delegate before calling SOAPEncoder."],"exampleFix":"// before\nvoid create(T entity);\n// after\nvoid create(Order entity);","handlingStrategy":"type-guard","validationCode":"static boolean isSoapEncodable(Type type) { return type instanceof Class; }","typeGuard":"if (!isSoapEncodable(bodyType)) {\n  throw new IllegalArgumentException(\"SOAP body must be a concrete class\");\n}","tryCatchPattern":"try {\n  client.create(entity);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"SOAP only supports encoding raw types\")) {\n    // change parameter type to a concrete class\n  }\n  throw e;\n}","preventionTips":["Only pass concrete DTO classes as SOAP request bodies.","Do not parameterize Feign SOAP interfaces over request types.","Enforce via interface conventions and review."],"tags":["soap","jaxb","generics","encoder","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}