2016-09-16 116 views
0

我有这样的HTTP POST服务:HTTP POST内容类型

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

xmlstr=string 

我想有这样的服务:

POST /test/test.asmx/getValues HTTP/1.1 
Host: localhost 
Content-Type: application/xml 
Content-Length: length 

xmlstr=string 

如何更改服务器的的Content-Type应用/ xml? 我正在使用IIS和VB .NET。

谢谢。

回答

0

Content-Type请求标头描述了请求主体中数据的格式。

xmlstr=string使用application/x-www-form-urlencoded格式进行编码。

如果你说Content-Type: application/xml那么我希望身体格式为XML(例如<xmlstr>string</xmlstr>)。

发送到服务器的Content-Type对服务器响应的数据类型没有标准化影响。

The Accept header可以请求特定内容类型:

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

xmlstr=string 

...但服务器端代码必须重视它,尊重它。

服务器还可能允许使用非标准请求标头,存储在URL的查询字符串中的数据或正文中的数据来请求特定格式。

它总是取决于服务器端代码支持的内容。