I am new to php client interaction with .NET web service. I have looked around and aware of posts like the one below but there are not the answer to my question.
How to make a PHP SOAP client and store the result xml in php variables
http://www.php.net/manual/en/soapclient.setsoapheaders.php
Consume a .Net web service using PHP
A PHP SOAP client (to request and get response) is needed for .NET web service (http://localhost:8080/someexample/myservice.wsdl). The input/request would look like this:
<input>
<the_input name="secondyear">
<authen>
<Teacher>
<teacherid>MrX</teacherid>
<password>t_pass</password>
</Teacher>
<Student>
<studentid>kids</studentid>
<password>s_pass</password>
</Student>
</authen>
<parameters>
<parameter name="maths" value="123" />
<parameter name="physics" value="abc" />
<parameter name="sports" value="def" />
</parameters>
</the_input>
</input>
Here is what i got but not working and i am not sure i am on the right track:
<?php
require_once("lib/nusoap.php");
$url="http://example.com/someexample/myservice.wsdl";
$client = new SoapClient($url);
$teacherid='MrX';
$tpassword='t_pass';
$studentid='kids';
$spassword='s_pass';
$ns = "http://example.com/";
//Body of the Soap Header.
$headerbody = array ('Teacher' => array('teacherid' => $teacherid,
'password' => $tpassword ),
'Student' => array('stendentid' => $studentid,
'password' => $spassword ));
//Create Soap Header.
$header = new SOAPHeader($ns, 'Authen', $headerbody);
//set the Headers of Soap Client.
$headerparam=$client->__setSoapHeaders($header);
$name ='secondyear';
$service_name = array('the_input'=>$name);
$result =$client->__SoapCall($service_name,$headerparam)
print_r ($result);
?>
I read somewhere in order to authenticate to a web service, one should put authentication parameter in php header, so what goes to the php body then or is it needed? is it the parameters? The parameter has the format of name and value, how do i do that in php array? is any relevant example available? as mentioned i've done my research and not clear how to solve this problem.