我在發送安全wse頭文件以使用web服務時遇到了問題,並且已經嘗試了幾種從TargetProcess.com使用此webservice的方法,我不確定我在做什麼錯誤。在php5通過soap發送安全wse頭文件
(http://demo.tpondemand.com/Services/ProjectService.asmx?wsdl)
他們的示例使用一個非常老版本的NuSOAP的,但我試圖做到這一點使用PHP5內置SoapClient類外。
我被困在接收錯誤的請求錯誤或無法進行身份驗證。那麼我怎樣才能發送這些頭文件?
這是我迄今爲止,但不工作:
$tp_header_part = '
<wsa:Action>
http://targetprocess.com/RetrieveAll
</wsa:Action>
<wsa:MessageID>
urn:uuid:'.$this->getGuid().'
</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://medios.tpondemand.com/Services/ProjectService.asmx</wsa:To>
<wsse:Security SOAP-ENV:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="SecurityToken-'.$this->getGuid().'">
<wsse:Username>MYUSERNAME</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
MYPASSWORD
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>';
$soap_var_header = new SoapVar($tp_header_part, XSD_ANYXML, null, null, null);
$soap_header = new SoapHeader('http://schemas.xmlsoap.org/ws/2003/06/secext', 'Security', $soap_var_header);
$client->__setSoapHeaders($soap_header);
P.S簡單地產生每它們的文檔該電源線一個GUID的getGuid功能。
任何想法?
想知道你是否能夠得到這個工作?我正嘗試在PHP中連接.NET SOAP API,這是一場噩夢。 – 2012-08-13 13:48:02