WSE 3.0 设置内容类型
我有一个简单的问题要问你,但我似乎无法理解。
情况如下:
- 我们使用 WSE 3 创建并向 Web 服务发送请求。Web
- 服务是用 Java 编写的。
大多数事情都很好,但我似乎无法对 WebResuest 或 WebResponse 的 ContentType 产生影响,这会导致一些问题。
我不断收到的错误消息如下:
客户端发现响应内容类型为“application/xop+xml;type="text/xml;charset=utf-8"”,但预期为“text/xml”。 请求失败并显示错误消息: ....
在错误消息的详细信息中,它包含对来自服务器的调用的响应,并且它正确通过。 显然,目前情况并不好,因为它遇到了异常:)。
那么,如何设置响应的预期内容类型?
如果我是正确的,WSE 3.0 中的请求和响应必须具有相同的 ContentType。 所以我想我会尝试将 request.Headers[HttpRequestHeader.ContentType] 设置为预期的值,但没有运气。 (另外,我可以在很多地方设置 HttpWebRequest 的内容类型,但它们似乎都不起作用)
I've a simple question, for you, that I just can't seem to get my head around.
The situation is the following:
- We create and send a request to a web service, using WSE 3.
- The web service is written in Java.
Most of the things are fine, but I can't seem to have an impact on the ContentType of either the WebResuest or WebResponse and that's causing some problems.
The errormessage I keep getting is the following:
Client found a response content type of ' application/xop+xml;type="text/xml; charset=utf-8" ' but expected 'text/xml'.
The request failed with the error message: ....
In the details of the error message it has the response to our call from the server and it's coming through properly.
Obviously it's not good as it is at the moment as it's coming through an exception :).
So, how could I set the expected content type for the response?
If I'm correct, the Request and the Response in WSE 3.0 has to have the same ContentType. So I thought I would try to set the request.Headers[HttpRequestHeader.ContentType] to the expected one, but with no luck. (also, I can set the HttpWebRequest's contenttype in quite a few places, but none of them seem to do the trick)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
幸运的是,这个问题已经解决了,所以这里是供将来参考的解决方案:
我们的客户端继承自WebServicesClientProtocol类,其中有一个名为GetWebResponse(..)的方法。
简单地覆盖该方法并更改响应的 ContentType 似乎对我们有用。
This has been solved luckily, so here's the solution for future reference:
Our client inherits from the WebServicesClientProtocol class, in which there's a method called GetWebResponse(..).
Simply overriding that method and changing the ContentType of the Response seemed to work out for us.