【发布时间】:2011-02-12 17:57:00
【问题描述】:
我在发送安全 wse 标头以使用 Web 服务时遇到问题,我已经尝试了几十种从 TargetProcess.com 使用此 Web 服务的方法,但我不确定自己做错了什么。
(http://demo.tpondemand.com/Services/ProjectService.asmx?wsdl)
他们的示例使用了一个非常旧版本的 Nusoap,但是我正在尝试使用内置在 SoapClient 类中的 php5 来做到这一点。
我在收到错误请求错误或无法进行身份验证之间陷入困境。那么如何发送这些标头呢?
这是我目前所拥有但不起作用的:
$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 getGuid 函数只是根据他们的文档生成了一个 guid。
有什么想法吗?
【问题讨论】:
-
想知道您是否能够使其正常工作?我正在尝试连接 PHP 中的 .NET SOAP API,这简直是一场噩梦。