| Author |
JAX-WS Client - Unsupported Content-Type issue
|
Raja Reddy
Greenhorn
Joined: Oct 29, 2002
Posts: 8
|
|
I am getting below exception while consuming JAX-WS 2.0 webservice using dispatch client API. Please suggest how to set the right content type in the request. SOAP binding used in the service is having 1.2 version.
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/xml;charset=utf-8 Supported ones are: [application/soap+xml]
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:291)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:128)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:294)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:173)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:88)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.client.Stub.process(Stub.java:248)
at com.sun.xml.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:180)
at com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:206)
at Test.main(Test.java:87) [/b]
Below is the client code I am using
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.Service.Mode;
import com.sun.xml.ws.spi.ProviderImpl;
import com.dp.xrm.common.xml.XmlUtil;
import javax.xml.ws.soap.SOAPBinding;
// Qnames for service as defined in wsdl.
QName serviceNameQName =
new QName(namespace, serviceName);
//QName for Port As defined in wsdl.
QName portNameQName =
new QName(namespace, portName);
// Create a dynamic Service instance
Service service = Service.create(serviceNameQName);
// Add a port to the Service
service.addPort(portNameQName, SOAPBinding.SOAP12HTTP_BINDING, "https://ctaa.xml.com/ctaa/sys2/pps");
//Create a dispatch instance
Dispatch<SOAPMessage> dispatch =
service.createDispatch(portNameQName, SOAPMessage.class, Service.Mode.MESSAGE);
MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
//MessageFactory mf = MessageFactory.newInstance();
SOAPMessage req = mf.createMessage();
req.getSOAPBody().addNamespaceDeclaration("tns", "http://vdaa.com/v_pps-v0-1-0.xsd");
SOAPElement element = req.getSOAPBody().addChildElement(operationName, "tns");
SOAPElement body = element.addChildElement(paramName , "tns");
SOAPElement customersRequestMessageIdElement=body.addChildElement("CustomersRequestMessageId", "tns");
customersRequestMessageIdElement.addTextNode("123");
SOAPMessage response = dispatch.invoke(req); exception is thrown from here
Regards,
Raja
|
SCJP 1.2, SCBCD 1.3 , SCWCD 5.0
|
 |
 |
|
|
subject: JAX-WS Client - Unsupported Content-Type issue
|
|
|