soap - PHP SoapClient and a complex header -


i have been trying while now, can't figure out how use php soapclient in combination wsdl form complex header (that is, more complex tutorial find). envelope need send looks this:

(001) <?xml version='1.0' encoding='utf-8'?>  (002) <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xlink="http://www.w3.org/1999/xlink">  (003) <soap-env:header>  (004) <eb:messageheader xmlns:eb="http://www.ebxml.org/namespaces/messageheader" eb:version="2.0" soap-env:mustunderstand="1">  (005) <eb:from>  (006) <eb:partyid>webservices.example.com</eb:partyid>   (007) </eb:from>  (008) <eb:to>  (009) <eb:partyid>clienturl</eb:partyid>   (010) </eb:to>  (011) <eb:cpaid>ipcc</eb:cpaid>   (012) <eb:conversationid>abc123@clienturl.com</eb:conversationid>   (013) <eb:service eb:type="xml">session</eb:service>   (014) <eb:action>sessioncreaters</eb:action>   (015) <eb:messagedata>  (016) <eb:messageid>mid:20030707-12545-1369@webservices.sabre.com</eb:messageid>   (017) <eb:timestamp>2001-02-15t11:25:12z</eb:timestamp>   (018) </eb:messagedata>  (019) <reftomessageid>mid:20001209-133003-2333@clienturl</reftomessageid>   (020) </eb:messageheader>  (021) <wsse:security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">  (022) <wsse:binarysecuritytoken xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/12/utility" wsu:id="sabresecuritytoken" valuetype="string" encodingtype="wsse:base64binary">shared/idl:icesess\/sessmgr:1\.0.idl/common/!icesms\/resc!icesmslb\/res.lb!-4954987477210575357!252506!0</wsse:binarysecuritytoken>   (023) </wsse:security>  (024) </soap-env:header>  (025) <soap-env:body>  (026) <eb:manifest xmlns:eb="http://www.ebxml.org/namespaces/messageheader" eb:version="2.0">  (027) <eb:reference eb:id="sessioncreaters" xlink:type="simple" xlink:href="cid:sessioncreaters"  (028) <eb:description xml:lang="en-us">response message</eb:description>"/>  (029) </eb:reference>  (030) </eb:manifest>  (031) </soap-env:body>  (032) </soap-env:envelope> 

i tried make using __setsoapheaders() , using soapvar(). can't right output though. examples learned use class fill parameters in xml, made class this:

class ebxmlmessage{  public $from = array('partyid' => 'www.example.com@example.com');  public $to = array('partyid' => 'example.com');  public $cpaid = 'xxxx';  public $conversationid = '12345@example.com';  public $service = 'session';  public $action = 'sessioncreaterq';  public $messagedata = array( 'messageid' => "mid:12345@example.com",'timestamp' => '2010-11-26t08:19:00z'); } 

than use:

$eb_params = new soapvar($eb,soap_enc_object); $header =  new soapheader($ns,"header", $eb_params,true); 

but request not begin has to:

<?xml version="1.0" encoding="utf-8"?> <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.opentravel.org/ota/2002/11" xmlns:ns2="https://cert.webservices.sabre.com/cert">  <soap-env:header>   <ns2:header soap-env:mustunderstand="1">    <from>     <item>      <key>partyid</key>      <value>www.example.com@example.com</value>     </item>    </from>    <to>     <item>      <key>partyid</key>      <value>webservices.sabre.com</value>     </item>    </to>    <cpaid>xxx</cpaid>    <conversationid>12345@example.com</conversationid>    <service>session</service>    <action>sessioncreaterq</action>    <messagedata>     <item>      <key>messageid</key>      <value>mid:12345@www.example.com</value>     </item>     <item>      <key>timestamp</key>      <value>2010-11-26t08:19:00z</value>     </item>    </messagedata>   </ns2:header>  </soap-env:header>  <soap-env:body>   <ns1:sessioncreaterq>    <ns1:pos>     <ns1:source pseudocitycode="xxxx"/>    </ns1:pos>   </ns1:sessioncreaterq>   <param1/>  </soap-env:body> </soap-env:envelope 

the main problems far getting right tags in xml on right place, , don't know how can "eb:" , "wsse:" namespace in tags. hoping use soapclienti() class i'm not sure if can handle more complex xml 1 need, if not maybe should use curl or similar , treat xml string?

i had issues when implementing wsse. here approach. yes, quite wsse-specific; however, should work in context well. note how there's 'wsse' namespace parameter in call new soapheader(). replace 'eb' case.

$header_part = '     <wsse:security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext" soap-env:mustunderstand="1">         <wsse:usernametoken>             <wsse:username>'."username".'</wsse:username>             <wsse:password>'."password".'</wsse:password>         </wsse:usernametoken>     </wsse:security> '; $soap_var_header = new soapvar( $header_part, xsd_anyxml, null, null, null ); $soap_header = new soapheader( 'http://your-target-service.com', 'wsse', $soap_var_header ); $soap_client->__setsoapheaders($soap_header); 

another solution mangle xml after subclassing soapclient, i'd last resort.

class my_soapclient extends soapclient {    protected $_response = null;    public function __dorequest( $request, $location, $action, $version, $one_way=null ) {       // insert big bad mangling code here       $this->_response = parent::__dorequest( $this->_request, $location, $action, $version, $one_way );       return $this->_response;    } } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -