简体   繁体   中英

Consuming PHP Web Service From C# Client

I am trying to consume a web service on an Apache/PHP server for which I only have the following example request as documentation.

POST /server/service.php HTTP/1.1
Host: server.example.com
ContentType: text/xml
ContentLength: xxx
<?xml version=\"1.0\"?>
<command>
    <parameters />
</command>

Every time I try to consume the service I get a HTTP 400 error. I have contacted the vendor of the software and they replied there is no problem with the server and attached a successful reply.

HTTP/1.1 200 OK
Date: 
Server: Apache/2.2.3 (Debian) PHP/5.2.0-8+etch7
X-Powered-By: PHP/5.2.0-8+etch7
Content-Length: 205
Connection: close
Content-Type: text/xml;charset=ISO-8859-1

<?xml version=\"1.0\"?>
<reply>
      <reply stuff />
</reply>

I have no idea what might be causing the HTTP 400 (Bad Request) response on my side. My best guess could either be an encoding problem of some sort or some incompatibility on the protocol side (or of course, bad programming).

Any help will be greatly appreciated!

考虑使用Fiddler来准确查看代码作为请求发送的内容(并考虑将请求发送到您自己的机器上用于测试的服务)。

you can use the WSDL.exe tool that microsoft provides, this tool can generate the proxy classes you need to connect to any web service that is SOAP compliant

also check that your XmlCommand is well formed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM