Home » , » Sending a header using the PHP SOAP client

Sending a header using the PHP SOAP client

Written By Unknown on Kamis, 25 Oktober 2012 | 10.38

You can create your own SOAP Client to send a header in a minute using PHP. PHP provides SOAP API which has numerous functions to create SOAP Client, initialize SOAP Header and also setting SOAP Header.

Actually when interacting with SOAP Server, the server requires a header to be sent which have API key. The header name will be APIKEY and the value will be the key itself. In example below the namespace is used for the API call is “MyNamespace”.
For initialization of SOAP client and set the header using PHP, you can do like below, where $wsdl_url is the URL of the WSDL file for the SOAP request:

$wsdl_url=“http://localhost/code/soap.wsdl”;
$soap_client = new SoapClient($wsdl_url);
$soap_header = new SoapHeader(‘ExampleNamespace’, ‘APIKey’, $apiKey);
$soap_client->__setSoapHeaders($soap_header);

Now you are ready to make requests to the SOAP server and the header will be sent with each time.
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger