我正在尝试this tutorial到我的项目:
我将标题SOAPAction
设置为http://somuri.com/IHubService/processAirLFSearch
我的身体看起来像:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://someuri.com">
<soapenv:Header/>
<soapenv:Body>
<OTA_AirLowFareSearchRQ>
...
</OTA_AirLowFareSearchRQ>
</soapenv:Body>
</soapenv:Envelope>
最后我的服务网址是:http://localhost:24030/HubService.svc
但我经常出现这个错误:
HTTP / 1.1 415无法处理消息,因为内容类型 'application / octet-stream'不是预期的类型'text / xml; 字符集= UTF-8' 。
我做错了什么?
答案 0 :(得分:1)
小提琴手拍摄的内容:
这是成功的请求标题
POST http://mycomputer:8989/MyService.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://someuri.com/Login"
Content-Length: 389
Host: mycomputer:8989
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
这是不成功的请求标题
POST http://mycomputer:8989/MyService.svc HTTP/1.1
SOAPAction: http://someuir.com/Login
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Accept: */*
Accept-Language: en-US
Accept-Encoding: GZIP
Host: mcomputer:8989
Content-Length: 1604
Expect: 100-continue
Connection: Keep-Alive
所以缺少
Content-Type:text / xml; charset = UTF-8
因此在Visual Studio中进行Web性能测试设置String体上的Content-type解决了问题