Why are the soap headers missing when using Custom MessageEncoder

喜你入骨 提交于 2019-12-12 00:12:30

问题


I am creating a custom message encoder similar to what you have in the WCF example projects(WF_WCF_Samples\WCF\Extensibility\MessageEncoder\Compression).

The problem I am having is when sending a request, using the default textMessageEncoder with no compression produces this request after encoding.

However, when I am using my custom encoder with gzip compression and sending a request from soapUI this is what I get.

As you can see the To and Action are missing. It ends up giving me this exception.

The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 

This can be remedied by adding the following manually in the MessageEncoder

message.Headers.To = new Uri("http://localhost:19860/Service1.svc");
message.Headers.Action = @"http://tempuri.org/IService1/GetData";

So my question is why is this happening? Why am I missing my headers when using the custom MessageEncoder even though I am just using the inner encoder to create the message?

Here is the full solution. To test it you just need soap ui and send request to http://localhost:19860/Service1.svc

https://github.com/janmchan/WCFCompression


回答1:


Finally found the issue. This seems to be a bug on WCF. The Action and To in SoapHeaders should not really be required on Soap 1.2 but for some reason even when using that version, I still get this issue with WCF only when using a custom MessageEncoder even if I'm just calling the inner encoder's ReadMessage. The solution is quite perplexing as well. As the error message suggest, the Action does not match the soap action so I just needed to add a header SOAPAction even if it is blank.

Here is the post that helped me find the solution.

WCF - SOAP Action mismatch error while testing with SoapUI



来源:https://stackoverflow.com/questions/37495848/why-are-the-soap-headers-missing-when-using-custom-messageencoder

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