title: PHP Nusoap - SOAP Request not working
body: <p>Hello i am very new to webservice, in php with below code i am trying to make soap request as shown in below XML, but it says Error</p>
  
  <blockquote>
    <p>HTTP Error: Unsupported HTTP response status 405 Method Not Allowed (soapclient->response has contents of the response)</p>
  </blockquote>
  
  <p>Questions:</p>
  
  <ol>
  <li>How to pass headers?</li>
  <li>How to pass FetchCalendarRequest with request like in XML?</li>
  </ol>
  
  <p>I have used Nusoap here but if you have a SOAP PHP class solution it is also invited.</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;?php
  
  require_once('../lib/nusoap.php');
  
  $client = new nusoap_client("http://webservices.test.com/ows/5.1/Availability.wsdl");
  $err    = $client-&gt;getError();
  
  if ($err)
  {
      client_debug_error_message('Constructor error', $err, $client);
      exit;
  }
  
  // Call the SOAP method
  $result = $client-&gt;call(
      'FetchCalendar', 
      array(
          'StayDateRange' =&gt; array(
              'StartDate' =&gt; '2013-10-01', 
              'EndDate'   =&gt; '2013-10-10',
          ),
      ),
  );
  
  // Check for a fault
  if ($client-&gt;fault) 
  {
      debug_preformatted('Fault', $result);
  } 
  else 
  {
      // Check for errors
      $err = $client-&gt;getError();
  
      if ($err) 
      {
          debug_preformatted('Error', $err);
      }
      else 
      {
          debug_preformatted('Result', $result);
      }
  }
  
  // Display the request and response
  client_debug_dump($client);
  </code></pre>
  
  <p><strong>XML</strong>  :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;soap:Header&gt;
      &lt;OGHeader transactionID="005435" timeStamp="2008-12-09T13:26:56.4056250-05:00" xmlns="http://webservices.test.com/og/4.3/Core/"&gt;
        &lt;Origin entityID="OWS" systemType="WEB" /&gt;
        &lt;Destination entityID="WEST" systemType="ORS" /&gt;
      &lt;/OGHeader&gt;
    &lt;/soap:Header&gt;
    &lt;soap:Body&gt;
      &lt;FetchCalendarRequest xmlns:a="http://webservices.test.com/og/4.3/Availability/" xmlns:hc="http://webservices.test.com/og/4.3/HotelCommon/" xmlns="http://webservices.test.com/ows/5.1/Availability.wsdl"&gt;
        &lt;HotelReference chainCode="AXA" hotelCode="AXAMUM" /&gt;
        &lt;StayDateRange&gt;
          &lt;hc:StartDate&gt;2013-10-01&lt;/hc:StartDate&gt;
          &lt;hc:EndDate&gt;2013-10-10&lt;/hc:EndDate&gt;
        &lt;/StayDateRange&gt;
        &lt;GuestCount&gt;
          &lt;hc:GuestCount ageQualifyingCode="ADULT" count="1" /&gt;
          &lt;hc:GuestCount ageQualifyingCode="CHILD" count="0" /&gt;
        &lt;/GuestCount&gt;
      &lt;/FetchCalendarRequest&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  
  
      Post Url :http://000.000.000.00:8080/ows_ws_51/Availability.asmx 
  Soap Action :  http://webservices.test.com/ows/5.1/Availability.wsdl#FetchCalendar
  </code></pre>
  
  <p><em>Edit:</em> <strong>Working Solution 16 Sep 2013</strong></p>
  
  <p>This solution is with Soap PHP Class only I want it to work with Nusoap bow.</p>
  
  <pre><code>&lt;?php
  
  $wsdl   = "http://###.###.###.##:8080/ows_ws_51/Availability.asmx?wsdl"; 
  $client = new SoapClient($wsdl, array(  'soap_version' =&gt; SOAP_1_1,'trace' =&gt; true,)); 
  
  //=========== Header Setting ============
  
  $ns                         = 'http://webservices.micros.com/og/4.3/Availability/'; //Namespace of the WS.//Body of the Soap Header.
  $strHeaderComponent_Session = &lt;&lt;&lt;XML
  &lt;OGHeader transactionID="005435" timeStamp="2008-12-09T13:26:56.4056250-05:00" xmlns="http://webservices.micros.com/og/4.3/Core/"&gt;
    &lt;Origin entityID="OWS" systemType="WEB" /&gt;
    &lt;Destination entityID="WEST" systemType="ORS" /&gt;
  &lt;/OGHeader&gt;
  XML;
  $objVar_Session_Inside      = new SoapVar($strHeaderComponent_Session, XSD_ANYXML, null, null, null);
  $objHeader_Session_Outside  = new SoapHeader($ns , 'SessionHeader', $objVar_Session_Inside);
  
  // More than one header can be provided in this array.
  $client-&gt;__setSoapHeaders(array($objHeader_Session_Outside));
  
  //============== Request ================
  
  $xml = &lt;&lt;&lt;XML
  &lt;FetchCalendarRequest xmlns:a="http://webservices.micros.com/og/4.3/Availability/" xmlns:hc="http://webservices.micros.com/og/4.3/HotelCommon/" xmlns="http://webservices.micros.com/ows/5.1/Availability.wsdl"&gt;
    &lt;HotelReference chainCode="AXA" hotelCode="{$DdlHotels}" /&gt;
    &lt;StayDateRange&gt;
      &lt;hc:StartDate&gt;{$Arrive}&lt;/hc:StartDate&gt;
      &lt;hc:EndDate&gt;{$Depart}&lt;/hc:EndDate&gt;
    &lt;/StayDateRange&gt;
    &lt;GuestCount&gt;
      &lt;hc:GuestCount ageQualifyingCode="ADULT" count="1" /&gt;
      &lt;hc:GuestCount ageQualifyingCode="CHILD" count="0" /&gt;
    &lt;/GuestCount&gt;
  &lt;/FetchCalendarRequest&gt;
  XML;
  
  $args = array(new SoapVar($xml, XSD_ANYXML));
  
  try 
  {
  
      $response = $client-&gt;__soapCall( 'FetchCalendar', $args );
  }
  catch (SoapFault $e) 
  {
      echo "Error: {$e}"; exit;
  }
  </code></pre>