SoapUI可以发送soap请求,java xml不能

SoapUI可以发送soap请求,java xml不能,java,soap,Java,Soap,我有一个项目,我必须向端点发出soap请求。使用SOAPUI,请求进行得非常顺利,我收到了一个响应,但是当我使用Java时,我收到了以下错误: com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post SEVERE: SAAJ0010: Unable to read response java.lang.NullPointerException 有人知道为什么会这样吗?以下是调用发生的部分: InputStre

我有一个项目,我必须向端点发出soap请求。使用SOAPUI,请求进行得非常顺利,我收到了一个响应,但是当我使用Java时,我收到了以下错误:

com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post SEVERE: SAAJ0010: Unable to read response
java.lang.NullPointerException
有人知道为什么会这样吗?以下是调用发生的部分:

InputStream is = new ByteArrayInputStream(message.getBytes("UTF-8"));
                MessageFactory factory = MessageFactory.newInstance();
                SOAPMessage soapMsg = factory.createMessage(null, is);
                SOAPConnectionFactory connFactory = SOAPConnectionFactory.newInstance();
                SOAPConnection conn = connFactory.createConnection();
                URL endpoint = new URL(Main.SOAP_END_POINT_TESTING);
                System.out.println(endpoint);

                SOAPMessage response = conn.call(soapMsg, endpoint); //right here is where the error is thrown
连接是通过普通HTTP进行的,请尝试以下操作:

SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();

MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();

SOAPEnvelope envelope = soapPart.getEnvelope();
您必须在此处创建正文,然后保存更改。

soapMessage.saveChanges();
打印请求消息

ByteArrayOutputStream outRequest = new ByteArrayOutputStream();
soapMessage.writeTo(outRequest);
String request=outRequest.toString();

SOAPMessage soapResponse = soapConnection.call(soapMessage,url);

因此将有两个未使用的变量:信封和请求?我不理解您示例信封中的代码流将用于在正文中添加数据。在SOAP中,每个元素都是父元素的子元素,每个SOAP请求都以信封开头(其余的标记都是它的子元素)。所以我们将把body添加到信封中。最后一个请求将用于打印我们通过SOAP发送的请求。您能提供请求示例吗?目前,不,它是专有的,所以我不能透露完整的请求。这也仅限于我的intranetI,我可以通过向连接资源添加连接超时来解决这个问题。我不明白这会如何影响那个特定的请求,但它起了作用。谁能把这个关上吗?