简体   繁体   English

从C#客户端使用PHP Web服务

[英]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. 我正在尝试在Apache / PHP服务器上使用Web服务,对此我只有以下示例请求作为文档。

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. 每次尝试使用该服务时,都会收到HTTP 400错误。 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. 我不知道是什么原因造成了我这一边的HTTP 400(错误请求)响应。 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 您可以使用Microsoft提供的WSDL.exe工具,该工具可以生成连接到与SOAP兼容的任何Web服务所需的代理类

also check that your XmlCommand is well formed 同时检查您的XmlCommand是否格式正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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