由WCF客户端使用PHP Web服务

时间:2013-10-09 08:05:04

标签: c# php wcf web-services httpwebrequest

我在使用WCF的PHP Web服务时遇到了问题。首先,我尝试通过“添加服务引用”来创建代理类,但这不起作用:

enter image description here

完整的错误消息:

There was an error downloading 'http://xxx.yyy.zzz.pl/Swdsoapserver/query?wsdl/_vti_bin/ListData.svc/$metadata'.
The request failed with the error message:
--
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Invalid XML</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

--.
Metadata contains a reference that cannot be resolved: 'http://xxx.yyy.zzz.pl/Swdsoapserver/query?wsdl'.
The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://xxx.yyy.zzz.pl/Swdsoapserver/query" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="SwdQuerySoap"
    targetNamespace="http://xxx.yyy.zzz.pl/Swdsoapserver/query">
    <wsdl:types>
        <xsd:schema 

我与人交谈,在php中托管这个网络服务,他说我,他使用这样的网络服务:

$Http = new Zend_Controller_Request_Http();
       $client = new SoapClient("http://".$Http->getServer('HTTP_HOST')."/Swdsoapserver/queryko?wsdl", array        ('trace'         => true));
       $object->sy = "12345678";
       $client->getParcel($object, base64_encode('xyzxyz'));

这个base64_encode('xyzxyz')是连接所需的哈希。

如何在C#.NET中使用此服务的任何建议

编辑:来自IE的屏幕: IE1 IE2 IE3

编辑:将文件保存在磁盘上并添加到visual studio(还有我的另外两个wcf服务) enter image description here

1 个答案:

答案 0 :(得分:1)

首先,您应该在您喜欢的导航器中浏览WSDL。将文件保存在本地编译器上。

第2步,您必须对此文件进行服务参考。它通常会为您项目中的PHP Web服务创建一个客户端(WCF)。

最后一步,您只需要在WCF中实例化客户端。