0

我无法使用 SOAP1.2 服务。我收到此错误:

com.sun.xml.internal.ws.server.UnsupportedMediaException:Unsupported 
Content-Type: text/xml Supported ones are: [application/soap+xml] 
at 
com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode
(StreamSOAPCodec.java:220)

以下是 WSDL 详细信息和生成的 Java 客户端:

<wsdl:operation name="redeem">
<soap12:operation 
       soapAction="http://org.comp.PartnerService
       /PartnerConnectorResponder/redeem" style="document" />

-----------------------------------------------------------------------
Client (WSImport Generated)
-----------------------------------------------------------------------

/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.8
* Generated source version: 2.2
* 
*/

@WebServiceClient(name = "PartnerService", targetNamespace = 
"http://tempuri.org/", wsdlLocation = "/jaxws/PartnerService_1.wsdl")
public class PartnerService extends Service
{
   @WebEndpoint(name = "WSHttpBinding_PartnerConnectorResponder")
   public PartnerConnectorResponder getConnectorResponder() {
       return super.getPort(
              new QName("http://tempuri.org/", 
              "PartnerConnectorResponder"), 
              ,PartnerConnectorResponder.class);
   }
}

-----------------------------------------------------------------------
Invocation: [Pseudo code]
-----------------------------------------------------------------------
fun redeem() {
   var soapClient:PartnerConnectorResponder = getConnectorResponder()
   var bindingProvider:BindingProvider=(soapClient asBindingProvider)

   bindingProvider.getRequestContext().put("Content-Type", "application/soap+xml")

   //Also tried lower 't' in type but no luck
   //bindingProvider.getRequestContext().put("Content-type", "application/soap+xml")

   bindingProvider.redeem();
}

该代码以某种方式设置了 SOAP 1.1 (text/xml) 的默认内容类型。即使我手动设置了内容类型,它仍然会失败并出现同样的错误。

我真的很感激任何投入,因为我已经被困了一个星期了。谢谢。

4

1 回答 1

1

通过向 SOAP 客户端添加以下属性来解决它: AddressingFeature(true)

于 2018-10-04T02:01:34.987 回答