我是新的PHP客戶端與.NET的Web服務交互。我環顧四周,意識到下面的帖子,但是我的問題沒有答案。.NET的Web服務和PHP客戶端
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
甲PHP SOAP客戶端(請求並獲取響應)需要用於.NET網絡服務 (http://localhost:8080/someexample/myservice.wsdl)。輸入/請求是這樣的:
<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>
這裏是我得到了,但沒有工作,我不知道我在正確的軌道上:
<?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);
?>
我爲了驗證某處閱讀到一個Web服務,應該把身份驗證參數在PHP頭部,所以什麼去的PHP身體呢,還是它需要?它是參數嗎?該參數具有名稱和值的格式,我該如何做到這一點在PHP數組?有沒有相關的例子可用?如上所述,我已經完成了我的研究並且不清楚如何解決這個問題。