title: "Object reference not set to an instance of an object" error connecting to SOAP server from PHP
body: <p>I'm making my first attempt to connect to a SOAP server from PHP, and I'm not understanding how to log in and get the data I need.  The service I'm trying to connect to is the Hawley USA service <a href="http://hawleyusa.com/thcServices/StoreServices.asmx">http://hawleyusa.com/thcServices/StoreServices.asmx</a>).  I've been looking at a few posts on how to connect, and I get the basics.  I've verified that I have SOAP enabled in my PHP, and I'm just trying to get an inventory list.  Here's the code I'm using:</p>
  
  <pre><code>&lt;?php
  ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
  $wsdl_path = "http://hawleyusa.com/thcServices/StoreServices.asmx?WSDL";
  
  $login_id = 'mylogin_id';
  $password = 'mypassword';
  
  $client = new SoapClient($wsdl_path);
  
  try {
    echo "&lt;pre&gt;\n";
    print($client-&gt;InventoryList(array("LoginID" =&gt; $login_id, "Password" =&gt; $password)));
    echo "\n";
  }
  catch (SoapFault $exception) {
    echo $exception;      
  } 
  </code></pre>
  
  <p>However, when I run this code, I get this error:</p>
  
  <pre><code>SoapFault exception: [soap:Server] Server was unable to process request. ---&gt; Object reference not set to an instance of an object. in /Users/steve/Sites/mysite/hawley_client.php:12
  </code></pre>
  
  <p>When debugging, I can see the $client instance initiated, so I'm not sure why I'm getting this error.</p>
  
  <p>Second question: Am I passing the user ID and password correctly?</p>
  
  <p>Thanks.</p>
  
  <p><strong>Update</strong>: I threw in $client->__getLastRequest, and this is what I got:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"              xmlns:ns1="http://hawleyusa.com/thcServices/"&gt;
  &lt;SOAP-ENV:Body&gt;
  &lt;ns1:InventoryList/&gt;
  &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>So I can see that I'm  missing my login ID and password. How do I add them to my InventoryList call?</p>