0
嗨,我正在從php服務調用aps.net web服務。該服務使用搜索參數搜索兩個數據庫。我不知道如何將搜索參數傳遞給asp.net服務。代碼如下。 (目前還沒有搜索放慢參數,但即時通訊在它如何被傳遞到asp.net服務只是有興趣)從php調用asp.net web服務
$link = mysql_connect($host, $user, $passwd);
mysql_select_db($dbName);
$query = 'SELECT firstname, surname, phone, location FROM staff ORDER BY surname';
$result = mysql_query($query,$link);
// if there is a result
if (mysql_num_rows($result) > 0) {
// set up a DOM object
$xmlDom1 = new DOMDocument();
$xmlDom1->appendChild($xmlDom1->createElement('directory'));
$xmlRoot = $xmlDom1->documentElement;
// loop over the rows in the result
while ($row = mysql_fetch_row($result)) {
$xmlPerson = $xmlDom1->createElement('staff');
$xmlFname = $xmlDom1->createElement('fname');
$xmlText = $xmlDom1->createTextNode($row[0]);
$xmlFname->appendChild($xmlText);
$xmlPerson->appendChild($xmlFname);
$xmlSname = $xmlDom1->createElement('sname');
$xmlText = $xmlDom1->createTextNode($row[1]);
$xmlSname->appendChild($xmlText);
$xmlPerson->appendChild($xmlSname);
$xmlTel = $xmlDom1->createElement('phone');
$xmlText = $xmlDom1->createTextNode($row[2]);
$xmlTel->appendChild($xmlText);
$xmlPerson->appendChild($xmlTel);
$xmlLoc = $xmlDom1->createElement('loc');
$xmlText = $xmlDom1->createTextNode($row[3]);
$xmlLoc->appendChild($xmlText);
$xmlPerson->appendChild($xmlLoc);
$xmlRoot->appendChild($xmlPerson);
}
}
//
// instance a SOAP client to the dotnet web service and read it into a DOM object
// (this really should have an exception handler)
//
$client = new SoapClient('http://stuiis.cms.gre.ac.uk/mk05/dotnet/dataBind01/phoneBook.asmx?WSDL');
$xmlString = $client->getDirectoryDom()->getDirectoryDomResult->any;
$xmlDom2 = new DOMDocument();
$xmlDom2->loadXML($xmlString);
// merge the second DOM object into the first
foreach ($xmlDom2->documentElement->childNodes as $staffNode) {
$xmlPerson = $xmlDom1->createElement($staffNode->nodeName);
foreach ($staffNode->childNodes as $xmlNode) {
$xmlElement = $xmlDom1->createElement($xmlNode->nodeName);
$xmlText = $xmlDom1->createTextNode($xmlNode->nodeValue);
$xmlElement->appendChild($xmlText);
$xmlPerson->appendChild($xmlElement);
}
$xmlRoot->appendChild($xmlPerson);
}
// return result
echo $xmlDom
不回答你的問題,但是這是使用OData的http://blogs.msdn.com/interoperability/archive/2010/03/一個完美的方案16/OData兼容互操作性與淨java的PHP-iphone和 - more.aspx – 2010-03-27 02:53:13