java.lang.RuntimeException:无法编写SOAP消息

时间:2018-04-10 02:56:17

标签: java spring web-services soap weblogic12c

尝试从weblogic进行Soap调用并使用以下代码。但是出现了以下错误,我不确定响应是否来自Web服务。请帮忙。错误指向带有“System.out.println(”Response body“+ sMsg.getSOAPBody())的行号;”在下面的代码中。

        SOAPConnectionFactory soapConnectionFactory = 
        SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = 
                                   soapConnectionFactory.createConnection();            
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage(new 
        MimeHeaders(), new 
          ByteArrayInputStream(request.getBytes(Charset.forName("UTF-8"))));

        message.getMimeHeaders().addHeader("SOAPAction",soapAction);
        SOAPMessage sMsg = soapConnection.call(message, Url);

        System.out.println("Response body" +  sMsg.getSOAPBody());
        ByteArrayOutputStream soapResponseStream = new 
                                                    ByteArrayOutputStream();
        sMsg.writeTo(soapResponseStream);   
        output = soapResponseStream.toString("UTF-8");

        soapConnection.close();

出现以下错误:

      java.lang.RuntimeException: Unable to write SOAP Message
                   at 
oracle.j2ee.ws.saaj.util.XMLWriter.internalWriteElement(XMLWriter.java:173) 
[com.oracle.webservices.orasaaj-rt-api_12.1.3.jar:]
at oracle.j2ee.ws.saaj.util.XMLWriter.writeElement(XMLWriter.java:61) 
[com.oracle.webservices.orasaaj-rt-api_12.1.3.jar:]
    at oracle.j2ee.ws.saaj.util.XMLWriter.writeElement(XMLWriter.java:478)[com.oracle.webservices.orasaaj-rt-api_12.1.3.jar:]
    at oracle.j2ee.ws.saaj.soap.ElementImpl.toString(ElementImpl.java:1162)[com.oracle.webservices.orasaaj-rt-api_12.1.3.jar:]
    at java.lang.String.valueOf(String.java:2849)[:1.7.0_121]
    at java.lang.StringBuilder.append(StringBuilder.java:128)[:1.7.0_121]

1 个答案:

答案 0 :(得分:0)

此问题已得到解决。基本上问题是回应。响应中包含不正确的字符(标记),导致此问题。