0
我在创建从PHP应用程序到.NET Web服务的连接时遇到了一些麻烦。我在很多网站上看过要做什么,但似乎无法让它工作。PHP SoapClient连接到NET Web服务
Web服务需要用户名和密码,以及所有我试图做的是通过发送用户的ID来获得用户数据管理系统的一些用户资料数据。
这就是供应商说,SOAP请求应该是这样的:
POST /feed30/clientdataservice.asmx HTTP/1.1
Host: ws-ic-pilot.acme.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "GetUser"
<?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>
<GetUser xmlns="urn:Acme:ClientDataService">
<strUserId>string</strUserId>
</GetUser>
</soap:Body>
</soap:Envelope>
这里是我已经根据我在互联网上的各种网站上发现写的代码:
$client = new SoapClient('https://ws-ic-pilot.acme.com/feed30/clientdataservice.asmx
WSDL',Array("trace" => 1));
$header = new SoapHeader(
array(
'UserName' => 'myusername',
'Password' => 'mypassword',
'strUserID' => '12345'
));
$client->__setSoapHeaders($header);
$client->GetUser();
当我使用__getLastRequestHeaders和__getLastRequest我创建的SOAP消息如下所示:
POST /feed30/clientdataservice.asmx HTTP/1.1
Host: ws-pilot.acme.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.21
Content-Type: text/xml; charset=utf-8
SOAPAction: "GetUser"
Content-Length: 247
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:Acme:ClientDataService"><SOAP-ENV:Header/>
<SOAP-ENV:Body><ns1:GetUser/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
当我发布SOAP消息到.NET服务器我得到如下回应:
<ExceptionInfo>Exception Message: Security requirements are not satisfied because the
security header is not present in the incoming message.;Exception Target Method:
ValidateMessageSecurity</ExceptionInfo></detail>
</soap:Body></soap:Envelope>
任何人都可以提供一个建议/建议,我怎么解决这个问题?
在此先感谢您的帮助!