Call asp.net web service from php
<p>Hi im calling an aps.net web service from a php service. The service searches both databases with a search parameter. Im not sure how to pass a   search parameter to the asp.net service. Code is below. ( there is no search paramter currently but im just interested in how it would be passed to the asp.net service)</p>

<pre><code>$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) &gt; 0 ) {
   // set up a DOM object
   $xmlDom1 = new DOMDocument();
   $xmlDom1-&gt;appendChild($xmlDom1-&gt;createElement('directory'));
   $xmlRoot = $xmlDom1-&gt;documentElement;
   // loop over the rows in the result 
   while ( $row = mysql_fetch_row($result) ) {
      $xmlPerson = $xmlDom1-&gt;createElement('staff');
      $xmlFname = $xmlDom1-&gt;createElement('fname');
      $xmlText = $xmlDom1-&gt;createTextNode($row[0]);
      $xmlFname-&gt;appendChild($xmlText);
      $xmlPerson-&gt;appendChild($xmlFname);
      $xmlSname = $xmlDom1-&gt;createElement('sname');
      $xmlText = $xmlDom1-&gt;createTextNode($row[1]);
      $xmlSname-&gt;appendChild($xmlText);
      $xmlPerson-&gt;appendChild($xmlSname);
      $xmlTel = $xmlDom1-&gt;createElement('phone');
      $xmlText = $xmlDom1-&gt;createTextNode($row[2]);
      $xmlTel-&gt;appendChild($xmlText);
      $xmlPerson-&gt;appendChild($xmlTel);
      $xmlLoc = $xmlDom1-&gt;createElement('loc');
      $xmlText = $xmlDom1-&gt;createTextNode($row[3]);
      $xmlLoc-&gt;appendChild($xmlText);
      $xmlPerson-&gt;appendChild($xmlLoc);
      $xmlRoot-&gt;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-&gt;getDirectoryDom()-&gt;getDirectoryDomResult-&gt;any;
$xmlDom2 = new DOMDocument();
$xmlDom2-&gt;loadXML($xmlString);

// merge the second DOM object into the first
foreach ( $xmlDom2-&gt;documentElement-&gt;childNodes as $staffNode ) {
   $xmlPerson = $xmlDom1-&gt;createElement($staffNode-&gt;nodeName);
   foreach ( $staffNode-&gt;childNodes as $xmlNode ) {
      $xmlElement = $xmlDom1-&gt;createElement($xmlNode-&gt;nodeName);
      $xmlText = $xmlDom1-&gt;createTextNode($xmlNode-&gt;nodeValue);
      $xmlElement-&gt;appendChild($xmlText);
      $xmlPerson-&gt;appendChild($xmlElement);
   }
   $xmlRoot-&gt;appendChild($xmlPerson);
}

// return result
echo $xmlDom
</code></pre>
