title: How php nuSoap client transfer ComplexType to .NET SOAP server
body: <p>I am trying to create a client soap call using php nusoap to an existing SOAP server build on .NET that contains complexTypes. </p>
  
  <p>I want to call QueryTestCategory(see belows)</p>
  
  <p>And it has param searchTag and Call_Result that are string</p>
  
  <p>But param LGI is type of LoginInfo(struct LoginInfo { string User_Name; string Password; })</p>
  
  <p>So,how do I setup the parameters for QueryTestCategory?</p>
  
  <p>I perform a getTypes I receive the following</p>
  
  <pre><code>struct HelloWorld { }
  struct HelloWorldResponse { string HelloWorldResult; }
  struct QueryTestSuite { LoginInfo LGI; string searchTag; string Call_Result; }
  struct LoginInfo { string User_Name; string Password; }
  struct QueryTestSuiteResponse { ArrayOfSuiteInfo QueryTestSuiteResult; string Call_Result; }
  struct ArrayOfSuiteInfo { SuiteInfo SuiteInfo; }
  struct SuiteInfo { string Test_Suite_ID; string Test_Suite_Name; string Tag; string Owner; string Remark; }
  struct QueryTestCategory { LoginInfo LGI; string searchTag; string Call_Result; }
  struct QueryTestCategoryResponse { ArrayOfCategoryInfo QueryTestCategoryResult; string Call_Result; }
  struct ArrayOfCategoryInfo { CategoryInfo CategoryInfo; }
  struct CategoryInfo { string Test_Category_ID; string Test_Category_Name; string Tag; string Owner; string Remark; }
  struct QueryTestCase { LoginInfo LGI; string searchTag; string Call_Result; }
  struct QueryTestCaseResponse { ArrayOfTestCaseInfo QueryTestCaseResult; string Call_Result; }
  struct ArrayOfTestCaseInfo { TestCaseInfo TestCaseInfo; }
  struct TestCaseInfo { string Test_Case_ID; string Test_Case_Name; string Test_Case_Version; string Tag; string Entry_Point; string Test_Kit_Name; string Test_Kit_Version; string Extra_Parameter; string Estimate_Time; string Function_Team; string Remark; string Test_Log_Parser_Name; string Test_Log_Parser_Version; string Test_Log_Parser_Entry_Point; string Test_Log_Parser_Extra_Parameter; string Owner; }
  struct QueryTestResult { LoginInfo LGI; string TaskID; string Call_Result; }
  struct QueryTestResultResponse { string QueryTestResultResult; string Call_Result; }
  </code></pre>
  
  <p>I try this, but it fails</p>
  
  <pre><code>/*
   *  $Id: wsdlclient1.php,v 1.3 2007/11/06 14:48:48 snichol Exp $
   *
   *  WSDL client sample.
   *
   *  Service: WSDL
   *  Payload: document/literal
   *  Transport: http
   *  Authentication: none
   */
  require_once('lib/nusoap.php');
  $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
  $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
  $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
  $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
  $client = new nusoap_client('http://www.example.com/Query.asmx?WSDL', 'wsdl',
                          $proxyhost, $proxyport, $proxyusername, $proxypassword);
  $err = $client-&gt;getError();
  if ($err) {
      echo "Constructor error";
  }
  // Doc/lit parameters get wrapped
  $param = array('User_Name' =&gt; 'SSD_WS_01', 'Password' =&gt; 'SSD_WS_01', 'searchTag' =&gt; 'test', 'Call_Result' =&gt; '');
  $result = $client-&gt;call('QueryTestCategory', array('parameter' =&gt; $param), '', '', false, true);
  // Check for a fault
  if ($client-&gt;fault) {
  
      print_r($result);
  
  } else {
      // Check for errors
      $err = $client-&gt;getError();
      if ($err) {
          // Display the error
          echo 'Error;
      } else {
          // Display the result
          echo 'Result';
          print_r($result);
  
      }
  }
  </code></pre>
  
  <h1>I found ANSWER!</h1>
  
  <p>After reading this web page and many many other information</p>
  
  <p><a href="http://gznofeng.iteye.com/blog/951762" rel="nofollow">http://gznofeng.iteye.com/blog/951762</a></p>
  
  <p>My finally code is like below</p>
  
  <p>To sum up...</p>
  
  <p>create $param1 = new stdClass,set parameter via $param1->varName = 'something'</p>
  
  <p>That all!</p>
  
  <pre><code> 23 // Doc/lit parameters get wrapped
   24 //$param1 = array('User_Name' =&gt; 'SSD_WS_01', 'Password' =&gt; 'SSD_WS_01');
   25 $param1 = new stdClass();
   26 $param1-&gt;User_Name = 'SSD_WS_01';
   27 $param1-&gt;Password = 'SSD_WS_01';
   28 
   29 $result = $client-&gt;call('QueryTestCategory', array('LGI' =&gt; $param1, 'searchTag' =&gt; '' ), '', '', false, true);
   30 // Check for a fault
   31 if ($client-&gt;fault) {
   32     echo '&lt;h2&gt;Fault&lt;/h2&gt;&lt;pre&gt;';
   33     print_r($result);
   34     echo '&lt;/pre&gt;';
   35 } else {
   36     // Check for errors
   37     $err = $client-&gt;getError();
   38     if ($err) {
   39         // Display the error
   40         echo '&lt;h2&gt;Error&lt;/h2&gt;&lt;pre&gt;' . $err . '&lt;/pre&gt;';
   41     } else {
   42         // Display the result
   43         echo '&lt;h2&gt;WoW,Result&lt;/h2&gt;&lt;pre&gt;';
   44         print_r($result);
   45         echo '&lt;/pre&gt;';
   46     }
   47 }
  </code></pre>