2010-03-27 5 views
0

안녕하세요, PHP 서비스에서 aps.net 웹 서비스를 호출합니다. 이 서비스는 검색 매개 변수로 두 데이터베이스를 모두 검색합니다. 아니, asp.net 서비스에 검색 매개 변수를 전달하는 방법을 모르겠다. 코드는 다음과 같습니다.PHP에서 asp.net 웹 서비스 호출

$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 
+0

하지 질문에 대한 답변 그러나 이것은 하나로, OData http://blogs.msdn.com/interoperability/archive/2010/03/를 사용하는 완벽한 시나리오를 포함하여 클라이언트와 웹 서비스 16/odata-interoperability-with-net-java-php-iphone-and-more.aspx –

답변

0

당신은 혼합 PHP 일치에 대해 이야기, 아파치 스톤 헨지 프로젝트를보고 http://www.interoperabilitybridges.com/projects/apache-stonehenge을 할 수 있습니다 (그것이 asp.net 서비스로 전달 될 것입니다 방법에 어떤 검색 현재 있었던 파라미터하지만 메신저에만 관심이있다) ASP.NET에서 그

JAS