How do I mix message encoding types (Text/MTOM) in the Request & Response of a Web Service client application using WCF (or WSE 3)?

扶醉桌前 提交于 2019-12-02 19:28:50
Eric Schlosser

Yes you can send a text message and get an mtom reply(or vise versa)with WCF.

see...

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/480f1bc4-1fc4-40e9-a2ed-efcf3009d6ef

I researched a bit about this and the bad news is that from WCF point of view the request and response MUST use the same enconding. So yeah, the answer above is quite correct. You have to organize with service provider to enable MTOM on both request and response. The MTOM request will not have any impact on his application, apart from changing the SOAP mime-type, as far as I know.

Here is a reply I got on another forum. it basically says that the problem is with Axis2 on the Java side. Unfortunately, that is not under my control in this case.

cherry111 - Posted on Saturday, November 15, 2008 12:52:08 AM

You need change the configuration on your AXIS2 web service. You may know you can enable MTOM at two places. One is in service.xml and the other is in the axis.xml. Java recommends you set it in service.xml, but .net wse3.0 client does not like it. If you enable MTOM in axis.xml, it should work.

Yes WCF has that mandated requirement and NO, because you can work around it like i did.

I wrote a MultiContentTypeMessageEncoder that encapsulates 3 different encoders text, mtom and fi. I also plan to encapsulate a gpb encoder if possible and if there is a good reason to do so, in the future

[WSE 3.0] You can define a new class that inherits from your WSE3 proxy object with a single override method GetWebResponse.

In GetWebResponse method, you can simply choose if you want to use the mtom encoding according to the response's content-type.

After that, you have to use this proxy class instead of the generated one.

PS: The WSE3 proxy class have to be generated using wsewsdl3 as a WebClient (add this option /type:webClient to the commend line).

Reference: http://www.codeproject.com/Tips/46257/Solution-to-WSE-error-for-WSE-clients-needing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!