WSE 3.0 MTOM发送格式错误的Content-Type标头 [英] WSE 3.0 MTOM sending malformed Content-Type header
问题描述
我正在开发Web服务应用程序以符合CAQH CORE要求.我正在ASP.NET中进行此操作
2.0与WSE 3.0的连接,但遇到了一个我无法解决的问题.为了测试我的服务器应用程序,我已经在ASP.NET 2.0/WSE 3.0中编写了一个客户端应用程序,并且在客户端和服务器上均启用了MTOM.这是
发生了什么–当我从客户端发送MTOM编码的请求时,服务器以HTTP 500状态和错误消息" 无法通过有效操作处理请求
范围.请提供有效的肥皂动作. " 在使用Wireshark捕获HTTP请求后,我发现HTTP请求的标头中确实具有有效的Action元素.
肥皂信封,这就是我所认为的错误消息.显然不是.然后,我检查了HTTP Content-Type标头,发现缺少'action =" xxxx"参数.我验证了缺少的参数
是通过远程登录服务器并手动发送我使用Content-Type中存在的action参数构造的HTTP请求而导致错误的原因.服务器将其接收并成功处理.我的问题是我不能
找到任何方法使WSE提供正确的Content-Type标头.我意识到WSE 3.0现在已经过时了,但是,我的代码库是.NET 2.0,并且在不久的将来还有最后期限.有什么建议吗?
I’m in the process of developing a Web Service application for compliance with CAQH CORE requirements. I’m doing this in ASP.NET
2.0 with WSE 3.0 and I’ve run into an issue that I have as yet been unable to resolve. In order to test my server application, I have written a client app, also in ASP.NET 2.0 / WSE 3.0 with MTOM enabled on both the client and the server. Here’s
what’s going on – When I send an MTOM encoded request from the client, the server is responding with an HTTP 500 status and an error message of "Unable to handle request without a valid action
parameter. Please supply a valid soap action." After capturing the HTTP request with Wireshark, I found that the HTTP request does have a valid Action element in the Header of the
Soap Envelope, which is what I would’ve thought the error message referred to. Apparently not so. I then examined the HTTP Content-Type header and noticed that the ‘action="xxxx" parameter was missing. I verified that the missing parameter
is what’s causing the error by telneting to the server and manually sending an HTTP request that I constructed with the action parameter present in the Content-Type. The server took it and processed it successfully. My problem is that I cannot
find any way to make WSE supply the correct Content-Type header. I realize that WSE 3.0 is now outdated, however, my code base is .NET 2.0 and I have a deadline looming in the very near future. Any suggestions?
推荐答案
请尝试使用以下方法在WSE中设置ContentType:
首先,您的客户端应继承自WebServicesClientProtocol类,该类中有一个称为GetWebResponse(..)的方法.然后只需覆盖该方法并更改Response的ContentType:
Please try to set ContentType in WSE by using the following:
First your client should inherits from the WebServicesClientProtocol class, in which there's a method called GetWebResponse(..). Then simply overriding that method and changing the ContentType of the Response:
protected override WebResponse GetWebResponse(System.Net.WebRequest request)
{
WebResponse response = base.GetWebResponse(request);
response.Headers[HttpResponseHeader.ContentType] = "text/xml";
return response;
}
最好的问候,
彭爱美
Best Regards,
Amy Peng
这篇关于WSE 3.0 MTOM发送格式错误的Content-Type标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!