[英]Consuming PHP web service by WCF client
我在使用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服务)
首先,您应该在自己喜欢的导航器中浏览WSDL。 将文件保存在本地计算机上。
步骤2,您必须对此文件进行服务引用 。 通常,它将在您的项目中为您的PHP Web服务创建一个客户端(WCF)。
最后一步,您只需在WCF中实例化一个客户端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.