php - Sending secure wse headers via Soap in php5 -


i having problem sending security wse headers consume web services , tried several dozens way of using webservice targetprocess.com , not sure doing wrong.

(http://demo.tpondemand.com/services/projectservice.asmx?wsdl)

their example uses old version of nusoap, trying using php5 built in soapclient class.

i stuck between receiving bad request errors or unable authenticate. how can send these headers?

this have far doesn't work:

     $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 function generated guid requiered per documentation.

any ideas?

if target server written using .net/asp, can fussy getting "perfect" xml requests - example, when using namespace prefix, essential include declaration of namespace in xml well.

i can see several examples of namespaces in xml (wsa, wsse, soap-env), not appear delcared - , i'd surprised if php soapclient able automatically populate them. 1 appear have declared 'wsse' = 'http://schemas.xmlsoap.org/ws/2003/06/secext', through initiation of soapheader object.

if possible, put packet sniffer (e.g. fiddler2) between php , target server see being sent , received - can make lot easier track errors, , figure out why xml being rejected.

i'd suggest 2 modifications initial code, ought make "valid xml":

  • wsa:action - add xmlns:wsa="<url definition of wsa>"
  • soapheader - i'm not sure, since you've put namespace uri here might necessary include namespace prefix on object name:

    $soap_header = new soapheader( 'http://schemas.xmlsoap.org/ws/2003/06/secext', 'wsse:security', $soap_var_header ); 

most important thing though find way exact http conversation between php client , target server - , if can working example compare , contrast, makes life 100% easier!


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -