title: SOAP-ERROR: Encoding: Violation of encoding rules?
body: <p>Guys, I'm stuck, banging my head off the desk for the past few hours.</p>
  
  <p>I am trying to consume a service, and I have 8 other functions that I call that are almost IDENTICAL in nature to this one, but this one, results in a 'SOAP-ERROR: Encoding: Violation of encoding rules' error.</p>
  
  <p>Heres the function call (wsdl omitted for security):</p>
  
  <pre><code>    function CanLoadProduct($data){
  
      $client = new SoapClient('wsdl-url');
  
      $params = array('username'   =&gt; $this-&gt;username,
                      'password'  =&gt; $this-&gt;password,
                      'prod'      =&gt; $data['productid'],
                      'mdn'       =&gt; $data['mdn']);
  
      try {
          $reply = $client-&gt;__soapCall("CanLoadProduct", $params);
      } catch (Exception $e) {
          echo 'Error: ',  $e-&gt;getMessage(), "\n";
          print_r($params);
          die();
      }
  
      if( $reply['result'] == 1 ){
          return TRUE;        // 1 = true
      } else {
          return FALSE;
      }
  
  }
  </code></pre>
  
  <p>Ok so this function, connects to a webservice, the required elements are:
  username, password, prod, mdn, all 4 of which I supply as part of the $params array. Username/Pass are defined earlier, and do work fine, as the other 8 functions consume the web service without any problems.</p>
  
  <p>The $data[] array (that I pass to the function), contains:
  $data['productid']
  $data['mdn']
  nothing else is used.</p>
  
  <p>I am getting </p>
  
  <pre><code>SOAP-ERROR: Encoding: Violation of encoding rules
  </code></pre>
  
  <p>for some unexplained reason, and Googling this error gets me nowhere.  Anyone else run into this?  Running PHP 5.2.9-2.  The strange thing is this is identical to this function which works 100%:</p>
  
  <pre><code>    function GetPIN($productid){
  
      $client = new SoapClient('wsdl-url');
  
      $params = array('username'  =&gt; $this-&gt;username,
                      'password'  =&gt; $this-&gt;password,
                      'prod'      =&gt; $productid);
  
      try {
          $reply = $client-&gt;__soapCall("GetPIN", $params);
      } catch (Exception $e) {
          echo 'Error: ',  $e-&gt;getMessage(), "\n";
          die();
      }
          return $reply;
  }
  </code></pre>
  
  <p>Here is the WSDL (should have posted this first):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
      xmlns:tns="ready:test" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
      xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="ready:test"&gt;
  &lt;types&gt;
  &lt;xsd:schema targetNamespace="ready:test"
  &gt;
   &lt;xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /&gt;
   &lt;xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /&gt;
  &lt;/xsd:schema&gt;
  &lt;/types&gt;
  &lt;message name="CanLoadProductRequest"&gt;
    &lt;part name="username" type="xsd:string" /&gt;
    &lt;part name="password" type="xsd:string" /&gt;
    &lt;part name="prod" type="xsd:string" /&gt;    
    &lt;part name="mdn" type="xsd:string" /&gt;
    &lt;part name="esn" type="xsd:string" /&gt;&lt;/message&gt;
  &lt;message name="CanLoadProductResponse"&gt;
    &lt;part name="result" type="xsd:int" /&gt;&lt;/message&gt;
  &lt;portType name="CanLoadProductPortType"&gt;
    &lt;operation name="CanLoadProduct"&gt;
      &lt;input message="tns:CanLoadProductRequest"/&gt;
      &lt;output message="tns:CanLoadProductResponse"/&gt;
    &lt;/operation&gt;
  &lt;/portType&gt;
  
  &lt;binding name="CanLoadProductBinding" type="tns:CanLoadProductPortType"&gt;
    &lt;soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
    &lt;operation name="CanLoadProduct"&gt;
      &lt;soap:operation soapAction="{url-removed}" style="rpc"/&gt;
      &lt;input&gt;
          &lt;soap:body use="encoded" namespace="" 
             encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
      &lt;/input&gt;
      &lt;output&gt;
          &lt;soap:body use="encoded" namespace="" 
              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
      &lt;/output&gt;
    &lt;/operation&gt;
  &lt;/binding&gt;
  &lt;service name="CanLoadProduct"&gt;
    &lt;port name="CanLoadProductPort" binding="tns:CanLoadProductBinding"&gt;
  
      &lt;soap:address location="{url-removed}"/&gt;
    &lt;/port&gt;
  &lt;/service&gt;
  &lt;/definitions&gt;
  </code></pre>