SOAP 呼び出しを Java アプリケーションに統合しようとしています。オンラインでさまざまなチュートリアルに従いましたが、アプリケーションを実行すると でエラーが発生しsm.saveChanges()
、その行がコメントアウトされている場合は でエラーが発生しsm.writeTo(System.out)
ます。
以下はコードです:
//Create a SOAPConnection
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage sm = mf.createMessage();
SOAPPart sp = sm.getSOAPPart();
SOAPEnvelope sv = sp.getEnvelope();
SOAPHeader sh = sm.getSOAPHeader();
//SOAPHeaderElement headerElement = sh.addHeaderElement(sv.createName("Signature", "SOAP-SEC", "http://schemas.xmlsoap.org/soap/security/2000-12"));
SOAPBody sb = sm.getSOAPBody();
//sh.detachNode();
MimeHeaders headers = sm.getMimeHeaders();
headers.addHeader("SOAPAction", "\"\"");
//QName bodyName = new QName("http://quoteCompany.com", "GetQuote", "d");
//QName bodyName = new QName(msisdn, "GetRioInformationsRequest", "ser");
//QName bodyName = new QName("http://schemas.xmlsoap.org/soap/encoding/", "GetRioInformationsRequest", XMLConstants.DEFAULT_NS_PREFIX);
QName bodyName = new QName("http://quoteCompany.com/", "GetQuote", "ser");
//QName bodyName = sv.createQName("http://quoteCompany.com/", "GetQuote", "ser");
Name bodyName2 = sv.createName("GetQuote","ser", "http://quoteCompany.com/");
SOAPBodyElement bodyElement = sb.addBodyElement(bodyName2);
//QName qn = new QName("aName");
//Name qn = sv.createName("rioSearchRequest");
QName qn = new QName("returnCode");
SOAPElement quotation = bodyElement.addChildElement(qn);
//quotation.addChildElement(qn2);
//Name qn2 = sv.createName("msisdn");
//qn2.
//quotation.addAttribute(qn2, msisdn);
//quotation.addTextNode("TextMode");
quotation.addTextNode(msisdn);
System.out.println("Saving SOAP message.");
sm.saveChanges();
System.out.println("\n Soap Request:\n");
sm.writeTo(System.out);
System.out.println("Request Outputted for viewing.");
//URL endpoint = new URL("http://yourServer.com");
URL endpoint = new URL("http://127.0.0.1:8088/mockSoapBinding");
System.out.println("URL entered.");
SOAPMessage response = connection.call(sm, endpoint);
System.out.println("Resquest Sent!");
System.out.println(response.getContentDescription());
System.out.println("Response obtained!");
対応するエラーは次のとおりです。
XSL-1101: (Fatal Error) DOMSource node as this type not supported.
Jun 27, 2012 4:37:45 PM com.sun.xml.messaging.saaj.soap.MessageImpl saveChanges
SEVERE: SAAJ0539: Unable to get header stream in saveChanges
Jun 27, 2012 4:37:45 PM com.sun.xml.messaging.saaj.soap.MessageImpl saveChanges
SEVERE: SAAJ0540: Error during saving a multipart message
SOAP Call Issue: Error during saving a multipart message
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1209)
at com.application.package.SOAPCalls.SOAPCall(SOAPCalls.java:66)
at com.application.package.Main.<init>(Main.java:97)
at com.application.package.Main.main(Main.java:253)
Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to get header stream in saveChanges:
at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1179)
... 3 more
Caused by: java.io.IOException: XSL-1101: (Fatal Error) DOMSource node as this type not supported.
at com.sun.xml.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:306)
at com.sun.xml.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:317)
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:324)
at com.sun.xml.messaging.saaj.soap.MessageImpl.getHeaderBytes(MessageImpl.java:1020)
at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1171)
... 3 more
助言がありますか?