防止将SOAP消息与内容类型一起发送为“multipart / related”; [英] Prevent a SOAP message from being sent with content-type as "multipart/related"

查看:280
本文介绍了防止将SOAP消息与内容类型一起发送为“multipart / related”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Web服务客户端(代码由IBM RAD 7.5生成)向主机发送SOAP消息,并且它带有Web服务故障,并且主机日志中的消息显示为prolog中不允许的内容 。当我使用SoapUI或简单的apache HttpClient测试客户端发送相同的内容时,主机会收到并处理该消息,我得到预期的响应。

I am sending a SOAP message from a webservice client (code was generated by IBM RAD 7.5) to a host, and it with a webservice fault and a message that in the hosts' log reads as "content not allowed in prolog". When I send the same content with SoapUI or a simple apache HttpClient test client, the message is received and processed by the host, and I get the expected response.

目前为止据我所知,区别在于正在发送的HTTP头。

As far as I can tell, the difference is in the HTTP headers that are being sent.

RAD生成的客户:



POST /ws/mycompany/webservice/SomeWebServiceName/soap11 HTTP/1.1
Host: http://host.com/ws/mycompany/webservice/SomeWebServiceName/soap11
Accept: application/soap+xml,multipart/related,text/*
User-Agent: IBM WebServices/1.0
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Connection: Keep-Alive
SAVECONNECTION: 7814631881345232300226
IBM-WAS-CLIENT: TRUE
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_E54EE0B5F8ED486B811345232300773; type="application/xop+xml"; start=""; start-info="text/xml"
Content-Length: 2553
Date: Fri, 17 Aug 2012 19:38:20 GMT

--MIMEBoundaryurn_uuid_E54EE0B5F8ED486B811345232300773
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: 

<soapenv:Envelope...
--MIMEBoundaryurn_uuid_E54EE0B5F8ED486B811345232300773--

对于SoapUI:


POST /ws/mycompany/webservice/SomeWebServiceName/soap11 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 2732
Host: localhost:9111
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope...

使用apache HttpClient实现一个非常简单的客户端:

And a very simple client implemented using apache HttpClient:


POST /ws/mycompany/webservice/SomeWebServiceName/soap11 HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Transfer-Encoding: chunked
Host: localhost:9111

8da
<soapenv:Envelope... 
0

据我所知,这三者之间的区别在于由RAD生成的客户端生成的请求具有内容类型multipart并定义MIME边界。我无法访问主机系统,但似乎主机无法处理多部分消息。

As far as I can tell, the difference between these three is that the request generated by by the RAD-generated client has a content-type "multipart" and defines a MIME boundary. I don't have access to the host system but it seems that the host is not able to handle multipart messages.

有没有办法强制IBM客户端代码像SoapUI或HttpClient一样发送消息?

Is there a way to force the IBM client code to send the message as simply as SoapUI or the HttpClient?

推荐答案

看起来问题是在BindingProvider中将MTOM设置为 true

It looks like the problem was setting MTOM to true in the BindingProvider.

我将我的代码更改为:

    SOAPBinding soapBinding = (SOAPBinding) bindProvider.getBinding();
    soapBinding.setMTOMEnabled(false);

一切正常。我认为MTOM设置为 true ,因为应用程序中的其他客户端需要它,并且此代码看起来像是基于其他客户端的代码。由于此Web服务调用实际上不需要MTOM,因此将其关闭没有问题。

And everything worked fine. I think MTOM was set to true because other clients in the application needed it and this code looks like it was based on the other clients' code. Since this web service call doesn't actually need MTOM, turning it off was no problem.

另请参阅: http:// pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.wsfep.multiplatform.doc%2Finfo%2Fae%2Fae%2Ftwbs_enablemtom.html

这篇关于防止将SOAP消息与内容类型一起发送为“multipart / related”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆