OpenFeign/feign · error · UnsupportedOperationException

SOAP only supports encoding raw types. Found

Error message

SOAP only supports encoding raw types. Found %s

What it means

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.

Solutions

  1. Use a concrete request class as the parameter type.
  2. Split generic interfaces into concrete per-type interfaces.
  3. Pre-resolve generics in a custom Encoder delegate before calling SOAPEncoder.

Example fix

// before
void create(T entity);
// after
void create(Order entity);
Defensive patterns

Strategy: type-guard

Validate before calling

static boolean isSoapEncodable(Type type) { return type instanceof Class; }

Type guard

if (!isSoapEncodable(bodyType)) {
  throw new IllegalArgumentException("SOAP body must be a concrete class");
}

Try / catch

try {
  client.create(entity);
} catch (UnsupportedOperationException e) {
  if (e.getMessage() != null && e.getMessage().contains("SOAP only supports encoding raw types")) {
    // change parameter type to a concrete class
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Generic client interfaces parameterized over request DTOs; passing Map/list wrappers and expecting generic marshalling support.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10). Data as JSON: /api/errors/fdd28c2b900cc7e6. Report an issue: GitHub.

Appendix: source

Thrown at soap/src/main/java/feign/soap/SOAPEncoder.java:116

    this.jaxbContextFactory = builder.jaxbContextFactory;
    this.writeXmlDeclaration = builder.writeXmlDeclaration;
    this.charsetEncoding = builder.charsetEncoding;
    this.soapProtocol = builder.soapProtocol;
    this.formattedOutput = builder.formattedOutput;
  }

  public SOAPEncoder(JAXBContextFactory jaxbContextFactory) {
    this.jaxbContextFactory = jaxbContextFactory;
    this.writeXmlDeclaration = true;
    this.formattedOutput = false;
    this.charsetEncoding = StandardCharsets.UTF_8;
    this.soapProtocol = DEFAULT_SOAP_PROTOCOL;
  }

  @Override
  public void encode(Object object, Type bodyType, RequestTemplate template) {
    if (!(bodyType instanceof Class)) {
      throw new UnsupportedOperationException(
          "SOAP only supports encoding raw types. Found " + bodyType);
    }
    try {
      Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
      Marshaller marshaller = jaxbContextFactory.createMarshaller((Class<?>) bodyType);
      marshaller.marshal(object, document);
      SOAPMessage soapMessage = MessageFactory.newInstance(soapProtocol).createMessage();
      soapMessage.setProperty(
          SOAPMessage.WRITE_XML_DECLARATION, Boolean.toString(writeXmlDeclaration));
      soapMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, charsetEncoding.displayName());
      soapMessage.getSOAPBody().addDocument(document);

      soapMessage = modifySOAPMessage(soapMessage);

      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      if (formattedOutput) {
        Transformer t = TransformerFactory.newInstance().newTransformer();
        t.setOutputProperty(OutputKeys.INDENT, "yes");

View on GitHub (pinned to e2a1e27560)