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);
$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.
Posting Komentar