我在使用 WCF 使用 PHP Web 服务时遇到问题。首先,我尝试通过“添加服务引用”创建一个代理类,但这不起作用:
完整的错误信息:
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 托管这个 web 服务的人交谈,他说我,他以这样的方式使用这个 web 服务:
$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 的屏幕:
编辑:将文件保存在磁盘上并添加到 Visual Studio(还有我的另外 2 个 wcf 服务)