我試圖從SOAP服務器發送-retrive消息...無法解析的內容類型的返回SOAP請求(JAVA)
但
soapConnection.call(soapMessage, endpoint)
回報:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to parse content type: null
Hereis我的代碼:
String url = "https://pubcommission.api.cj.com/wsdl/version2/publisherCommissionServiceV2.wsdl";
String method = "findPublisherCommissionDetails";
SOAPConnection soapConnection = SOAPConnectionFactory.newInstance().createConnection();
SOAPFactory soapFactory = SOAPFactory.newInstance();
MessageFactory messageFactory = MessageFactory.newInstance();
// Create a message from the message factory.
SOAPMessage soapMessage = messageFactory.createMessage();
// creat a SOAP part have populate the envelope
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.setEncodingStyle(SOAPConstants.URI_NS_SOAP_ENCODING);
// remove all header information from envelope
envelope.getHeader().detachNode();
// create a SOAP body
SOAPBody body = envelope.getBody();
Name babelFishRequestName = envelope.createName(method, "ns1", "http://api.cj.com");
SOAPBodyElement soapMethod = body.addBodyElement(babelFishRequestName);
// add elements translationmode and sourcedata to BabelFishRequest
soapMethod.addChildElement(soapFactory.createElement("developerKey", "ns1", "http://api.cj.com").addTextNode("nevermind"));
soapMethod.addChildElement(soapFactory.createElement("originalActionIds", "ns1", "http://api.cj.com").addTextNode("1234567"));
// set the saves into the structure
soapMessage.saveChanges();
// output the message
System.out.println("\n============= start request msg ==========\n");
soapMessage.writeTo(System.out);
System.out.println("\n============= end request msg ==========\n");
URLEndpoint endpoint = new URLEndpoint(url);
System.out.println("\nSending message to URL: " + endpoint.getURL());
// now make that call over the SOAP connection
SOAPMessage reply = soapConnection.call(soapMessage, endpoint);
我想ü '膜'檢查結果並得到以下結果(RAW):
HTTP/1.0 500 Internal Server Error
Server: Resin/3.1.8
Content-Type: text/xml; charset=UTF-8
Date: Wed, 08 Feb 2012 10:45:47 GMT
X-Cache: MISS from proxy.myserver.com
X-Cache-Lookup: MISS from proxy.myserver.com:3128
Via: 1.0 proxy.myserver.com (squid/3.1.18)
Connection: close
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Action id specified does not match your account: 1234567</faultstring></soap:Fault></soap:Body></soap:Envelope>
您正在使用的URL指向WSDL,請嘗試將其替換爲實際的Web服務URL。 – TPete 2012-02-08 13:04:53
你的男人url:String url =「h ttps://pubcommission.api.cj.com」? – davs 2012-02-08 13:28:52
對不起,請忽略我的第一條評論。無法幫助你解決這個錯誤。請參閱下面的使用JAX-WS的方法。 – TPete 2012-02-08 14:17:29