這裏是我試圖撥打電話:從切換到的NuSOAP PHP5香皂 - 需要在JumpStart
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<urn:SessionHeader xmlns:urn="http://www.mywebservice.com/webservices/SoapService" xmlns="http://www.mywebservice.com/webservices/SoapService" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<urn:sessionId xmlns:urn="http://www.mywebservice.com/webservices/SoapService">LOGINTOKEN=your instance name</urn:sessionId>
</urn:SessionHeader>
</soap:Header>
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<ns2:login xmlns:ns2="http://www.mywebservice.com/webservices/SoapService">
<wsUser>
<entityId>0</entityId>
<password>your password</password>
<username>your username</username>
</wsUser>
</ns2:login>
</soap:Body>
但我有麻煩找出如何設置自定義首部中PHP5的肥皂。使用nuSoap,我可以將整個事物放入一個變量中,然後使用$client->setHeader($headerVar)
,但我在PHP中找不到任何類似的東西。如果我能複製這一個電話,我可以找出其他的問題。任何幫助,將不勝感激!
在此先感謝!
更新:我已經通過教程後的教程,並閱讀PHP文檔,但似乎沒有任何工作。我可以用curl(以及nuSoap)來做我想做的事情,但我認爲原生的PHP5 Soap會更容易,也更穩定。我想不是...
更新2 這裏有我想要的代碼:
$soapurl = 'http://www.mywebservice.com/webservices/SoapService?wsdl';
$client = new SoapClient($soapurl,array('trace'=>true));
$token = "LOGINTOKEN=your instance name";
$header = new SoapHeader('http://www.mywebservice.com/webservices/SoapService', 'SessionHeader', array('sessionId' => $token));
$client->__setSoapHeaders($header);
$client->login(array("wsUser" => array('entityId'=>'0','username'=>'my username','password'=>'my password')));
和錯誤,我得到:
**Fatal error**: Uncaught SoapFault exception: [ns1:InvalidSecurity] An error was discovered processing the <wsse:Security> header in C:\www\soap\index.php:12 Stack trace: #0 C:\www\soap\index.php(12): SoapClient->__call('login', Array) #1 C:\www\soap\index.php(12): SoapClient->login(Array) #2 {main} thrown in C:\www\soap\index.php on line 12
更新3 所以看起來像「sessionId」被髮送爲「密鑰」,令牌作爲「值」發送。
*REQUEST*:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.mywebservice.com/webservices/SoapService">
<SOAP-ENV:Header>
<ns1:SessionHeader><item><key>sessionId</key><value>LOGINTOKEN=my token</value></item>
</ns1:SessionHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body><ns1:login><wsUser><entityId>0</entityId><password>my password</password><username>my username</username></wsUser></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope>
SoapClient :: __ setSoapHeaders()不做你想要的東西? http://php.net/soapclient.setsoapheaders – Inigoesdr 2010-09-22 04:56:34
它可能,我已經嘗試過實現它,但我無法弄清楚如何使它返回確切的格式。 – TerryMatula 2010-09-24 14:15:27