在动态Web应用程序中使用javax.xml.soap

时间:2017-02-16 21:52:49

标签: java soap-client

我创建了一个使用javax.xml.soap创建SoapMessage的代码。 当我将这段代码作为java应用程序启动时,一切正常,但当我在tomcat上将其作为Web应用程序启动时,我将SoapMessage清空。

  1. 以java application
  2. 开头

    SOAPMessage message = MessageFactory.newInstance()。createMessage(); printSOAPMessage(消息);

    结果: SOAP消息=

    <?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body/></SOAP-ENV:Envelope>
    
    1. 作为网络应用程序启动
    2. SOAPMessage message = MessageFactory.newInstance()。createMessage(); printSOAPMessage(消息);

      结果: SOAP消息=( NOTHING

      private void printSOAPMessage(SOAPMessage soapMessage) throws Exception {
              TransformerFactory transformerFactory = TransformerFactory.newInstance();
              Transformer transformer = transformerFactory.newTransformer();
              Source sourceContent = soapMessage.getSOAPPart().getContent();
              System.out.print("\nSOAP Message = ");
              StreamResult result = new StreamResult(System.out);
              transformer.transform(sourceContent, result);
          }
      

0 个答案:

没有答案