title: XML error parsing SOAP payload on line 1: Not well-formed (invalid token)
body: <p>I'm trying to create a webservice with PHP and nuSoap but everytime I try to execute it I'm getting the error:</p>
  
  <blockquote>
    <p>XML error parsing SOAP payload on line 1: Not well-formed (invalid token)</p>
  </blockquote>
  
  <p>Can anyone see what's wrong?</p>
  
  <p>service.php</p>
  
  <pre><code>&lt;?php
  require 'lib/nusoap.php';
  
  $server = new nusoap_server();
  $server-&gt;configureWSDL("casamitger" . "urn:casamitger");
  $server-&gt;wsdl-&gt;schemaTargetNamespace = 'urn:casamitger';
  include 'functions.php';
  
  //getAvailabilities
  $server-&gt;wsdl-&gt;addComplexType('Availabilities','complexType','struct','all','',array(
     'StartDate' =&gt; array('name' =&gt; 'StartDate', 'type' =&gt; 'xsd:date'), 
     'EndDate' =&gt; array('name' =&gt; 'EndDate', 'type' =&gt; 'xsd:date'),
     'State' =&gt; array('name' =&gt; 'State', 'type' =&gt; 'xsd:string'), 
  ));
  
  $server-&gt;wsdl-&gt;addComplexType('ArrayOfAvailabilities', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(
      array('ref' =&gt; 'SOAP-ENC:arrayType', 'wsdl:arrayType' =&gt; 'tns:Availabilities[]')), 'tns:Availabilities');
  
  
  $server-&gt;register(
      'getAvailabilities',
      array(
          "SessionID"       =&gt; 'xsd:string', 
          "AccommodationId" =&gt; 'xsd:integer'
      ),
      array("return" =&gt; 'tns:ArrayOfAvailabilities')
  );
  
      $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  $server-&gt;service($HTTP_RAW_POST_DATA);
  ?&gt;
  </code></pre>
  
  <p>functions.php</p>
  
  <pre><code>function getAvailabilities($sessionID, $accommodation_code) {
      $connection = mysqli_connect("localhost", "root", "", "casamitger");
      if (authenticate($sessionID)) {
          $user = getUser($sessionID);
          $query = mysqli_query($connection, "SELECT count(AccommodationId) c FROM UserAccommodations WHERE AccommodationId = '$accommodation_code' AND CompanyId = '$user'") or die();
          $row = mysqli_fetch_object($query);
          $count = $row-&gt;c;
          if ($count &gt; 0) {
              $query = mysqli_query($connection, "SELECT StartDate,EndDate,State FROM Availabilities WHERE AccommodationId = '$accommodation_code'") or die();
              $n = 0;
              while ($row = mysqli_fetch_object($query)) {
                  $result[$n]['StartDate'] = $row-&gt;StartDate;
                  $result[$n]['EndDate'] = $row-&gt;EndDate;
                  $result[$n]['State'] = $row-&gt;State;
                  $n++;
              }
              return $result;
          }
      }
  }
  </code></pre>
  
  <p>and the client.php</p>
  
  <pre><code>&lt;?php
  
  require 'lib/nusoap.php';
  include 'functions.php';
  
  $sessionid          = '1234';
  $accommodation_code = '83081';
  
  $client = new nusoap_client("http://192.168.8.155:8090/ws/service.php?wsdl");
  
  $availabilities = $client-&gt;call(
      'getAvailabilities', 
      array(
          "SessionID"       =&gt; "$sessionid", 
          "AccommodationId" =&gt; "$accommodation_code",
      )
  );
  
  if ($client-&gt;fault) {
      echo 'Fault';
  } else {
      $err = $client-&gt;getError();
      if ($err) {
          echo $err;
      } else {
          print_r($servicetypes);
      }
  }
  ?&gt;
  </code></pre>
  
  <p>If I call the method getAvailabilities() directly it works but it doesn't through the web service, any help will be appreciated, thanks.</p>