当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - visual studio Web Service Request 415 error

问题描述:

I am trying to this tutorial to my project:

I set header: SOAPAction as http://somuri.com/IHubService/processAirLFSearch

and my body looks like:

<?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>

finally my url to service is: http://localhost:24030/HubService.svc

But I constantly this error:

HTTP/1.1 415 Cannot process the message because the content type

'application/octet-stream' was not the expected type 'text/xml;

charset=utf-8'.

What am I doing wrong?

By the way here what looks like my project screen shot:

网友答案:

What captured in fiddler:
This is successful request header

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)

and this is unsuccessful request header

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

So it is missing

Content-Type: text/xml;charset=UTF-8

So in visual studio in web performance test setting Content-type on String body solves problem

分享给朋友:
您可能感兴趣的文章:
随机阅读: