(急)请问如何取得web service响应中的Content-type属性值?

ejbcreate 2004-01-02 03:39:27
请问各位大侠,如何取得web service响应中的Content-type属性值以及如何设置Content-type属性的值?
希望各位能提供帮助,不胜感激!


HTTP GET
下面是一个 HTTP GET 请求和响应示例。所显示的占位符需要由实际值替换。

GET /TestWebService/test.asmx/HelloWorld? HTTP/1.1
Host: localhost

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>

HTTP POST
下面是一个 HTTP POST 请求和响应示例。所显示的占位符需要由实际值替换。

POST /TestWebService/test.asmx/HelloWorld HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length


HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>
...全文
409 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ejbcreate 2004-01-07
  • 打赏
  • 举报
回复
已经搞定了,多谢各位。
rottenapple 2004-01-06
  • 打赏
  • 举报
回复
to sunmast:
昨天无意间看了你的blog,不错不错,说实话,我在上学期间可没有你这么好学,就玩了。
rottenapple 2004-01-06
  • 打赏
  • 举报
回复
.net 的帮助,可惜我的是英文版,将就看了,希望能满足你的要求
Property Value
A CookieContainer that represents the cookies for a Web Services client.

Remarks
If an XML Web service method uses session state, then a cookie is passed back in the response headers to the XML Web service client that uniquely identifies the session for that XML Web service client. In order for an XML Web service to maintain session state for a client, the client must persist the cookie. Clients can receive the HTTP cookie by creating a new instance of CookieContainer and assigning that to the CookieContainer property of the proxy class before calling the XML Web service method. If you need to maintain session state beyond when the proxy class instance goes out of scope, the client must persist the HTTP cookie between calls to the XML Web service. For instance, a Web Forms client can persist the HTTP cookie by saving the CookieContainer in its own session state. Because not all XML Web services use session state and thus clients are not always required to use the CookieContainer property of a client proxy, the documentation for the XML Web service should state whether session state is used.
ejbcreate 2004-01-06
  • 打赏
  • 举报
回复
非常感谢各位的帮助,特别感谢: rottenapple(烂苹果)和Sunmast(速马) .
我会试试你们的方法的。
或者如果我找到一些更好的方法,会第一时间告诉大家。
祝福大家!
rottenapple 2004-01-06
  • 打赏
  • 举报
回复
to xiaocao:
看了你的短消息,我想我明白了你的想法。你是不是想把别人写在soap header中的信息取出来?如果是,用我上面提到的wse很方便的,
http://msdn.microsoft.com/webservices/building/wse/default.aspx
你可以参考看看,有问题可以发短消息
rottenapple 2004-01-06
  • 打赏
  • 举报
回复
小草:
很不好意思,上面的回答我有些不负责任了,没有试验过就想当然了。主要前一阵的我用过类似的技术,今天看了看才发现原来我们的要求是不一样的。我想你可以用微软提供的WSE1.0sp1来实现它。不过要求你的客户端要安装它,就是几个dll。它本身有几个例子,估计你能明白的。wse可以使你生成一个proxy,然后用这个proxy去掉用这个webservice。这个proxy的主要代码就是你用.net工具添加web 引用后在web引用文件夹里面的reference.cs文件,只不过把继承的类改成了wse提供的一个类。这样,你就可以控制客户端调用的时候一些参数,比如token等。同样,它提供了一个ResponseSoapContext类,我想可以满足你的要求。
其实,我也不想用额外的东西来实现,只是我的技术也只知道这些。默认继承的SoapHttpClientProtocol也许可以看看它的内部,或者它的super calss
希望可以帮上你,有更好的解决方案也可以告诉我,谢谢
rottenapple 2004-01-05
  • 打赏
  • 举报
回复
HttpContext.Current.Response.ContentType webservice设定

如果你用asp.net call webservice那么方法类似上面的

如果是winform,那么可能需要自己取得整个http响应解析了
rottenapple 2004-01-05
  • 打赏
  • 举报
回复
HttpContext.Current.Request.ContentType 服务器端
速马 2004-01-05
  • 打赏
  • 举报
回复
WebService返回值(页面)的ContentType应该全部是text/xml
ejbcreate 2004-01-02
  • 打赏
  • 举报
回复
我是想在调用web service中的方法后,取得响应的Content-Type属性值。
希望各位能指点迷津。
ktaka 2004-01-02
  • 打赏
  • 举报
回复
帮顶一下!

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧