简体   繁体   中英

NuSOAP Header Authentication PHP Webservice

I am new to SOAP webservices and I need to develop a SOAP Server Webservice that authenticates with the header information. I am using NuSOAP as it seems to be a pretty helpful class. I can find a lot of information in regards to the client side of making SOAP calls, but nothing that is very information on the server side. Looking for any guidance or tutorials for the server side of SOAP.

Here is what I have thus far, I'm not sure if this is the proper way to handle the authentication or if there are built in methods:

$server = new nusoap_server();
$server->configureWSDL("ProjectName", "name:space");

$server->register(

    "authenticate",
    array("UserName"=>"xsd:string",
           "Password"=>"xsd:string",
           "MessageText"=>"xsd:string"),
    array("return"=>"xsd:string")

);

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

function authenticate($UserName, $Password, $MessageText) {

}

Thanks for helping a SOAP Noobie!! :)

You can access the header data by parsing the HTTP_RAW_POST_DATA as XML and using a generic XML library to do what ever is needed.

$data = $HTTP_RAW_POST_DATA;        

$doc = new DOMDocument();
$doc->loadXML($data);
$doc->getElementsByTagName('UserName')->item(0)->nodeValue;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM