Reputation: 339
I am having trouble consuming a SOAP1.2 service. I am getting this error:
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)
Here are the WSDL details and the generated Java clients:
<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();
}
The code is somehow setting the default content type of SOAP 1.1 (text/xml). Even after I manually set the content type, it still fails with the same error.
I would really appreciate any inputs as I have been stuck for a week now.Thank you.
Upvotes: 0
Views: 734
Reputation: 339
Solved it by adding the following property to the SOAP Client: AddressingFeature(true)
Upvotes: 1