Friday, April 4, 2014

How to process Soap header in php SoapServer

To process soap header request in our PHP SOAP Server Example, we will add to our PHP server class, a function with the same name as the header element we are trying to process. Please ensure that you are using the latest version of PHP to avoid any weird behaviour.


See How To Add Header Message To WSDL, on how we created the header element. For this example, our header element is named, requestHeader. So we will create a function  in our server class, with the same name, requestHeader.
The requestHeader element is a complexType with two parameters, which we can process in php as an associative array with two keys.



Our requestHeader function will be called if soap request contains "requestHeader" in SOAP header. For demonstration, we simply stored the requestHeader parameters, username and password, in a private variable, headerInfo, and returned this info back to the client in the boom() function. See the complete server codes below;


The updated client version, on how to add SOAP Header request to PHP SOAP Client, will be available soon.

1 comment:

  1. Hi, Please any help me
    wsdl authentication [requestHeader function ]not working for me.

    Thanks in advance

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...