在.NETWeb服务上使用PHP SOAP客户端
我正在尝试使用.NETSOAP服务,但我目前只得到一个“错误”响应 访问服务端点会告诉我以下信息:在.NETWeb服务上使用PHP SOAP客户端,php,web-services,soap,wsdl,Php,Web Services,Soap,Wsdl,我正在尝试使用.NETSOAP服务,但我目前只得到一个“错误”响应 访问服务端点会告诉我以下信息: The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values. <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="h
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendData xmlns="http://tempuri.org/">
<myObj>string</myObj>
</SendData>
</soap:Body>
</soap:Envelope>
所以我的问题是:请求模式的这种差异是导致请求失败的原因吗,还是这只是编写相同内容的另一种方式?如果它负责,是否可以完全按照端点指定的方式编写请求 这是一回事
在给定的示例中,
没有名称空间前缀(您自己的请求中的ns1
),因此使用默认前缀,并为其自身及其子体指定xmlns
属性
在您的请求中,
ns1
名称空间前缀是使用xmlns:ns1=”定义的http://tempuri.org/“
并在
中用于澄清,当我说'false'响应时-我不是说soapCall失败-我是说我从$soap->u getLastResponse()得到false;
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:SendData>
<ns1:myObj>My data</ns1:myObj>
</ns1:SendData>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
$soap = new SoapClient('wsdl.xml', array("trace" => 1, "exception" => 1));
$call = $soap->__soapCall("SendData", array("SendData" => array("myObj" => "My data")));