title: Calling Web Services with PHP SoapClient - How to?
body: <p>I am going crazy starting off with Web Services. I am trying to call the following WSDL using PHP and keep getting nowhere:</p>
  
  <p><a href="http://webservices.sabre.com/wsdl/sabreXML1.0.00/usg/SessionCreateRQ.wsdl" rel="nofollow noreferrer">http://webservices.sabre.com/wsdl/sabreXML1.0.00/usg/SessionCreateRQ.wsdl</a></p>
  
  <p>I found the following piece of code on the net, from someone with similar problems, but I could not get it to work either:
  <br><br><code>
  $soap = new SoapClient('<a href="http://webservices.sabre.com/wsdl/sabreXML1.0.00/usg/SessionCreateRQ.wsdl" rel="nofollow noreferrer">http://webservices.sabre.com/wsdl/sabreXML1.0.00/usg/SessionCreateRQ.wsdl</a>', 
                          array( 
                              'trace' => true, 
                              'soap_version' => SOAP_1_2, 
                              "exceptions" => 0)); </p>
  
  <p>$eb = new EbXmlMessage(); <br>
  $sec = new Security(); <br>
  $scrq = new SessionCreateRQ(); </p>
  
  <p>try { <br>
      $omg = $soap->SessionCreateRQ($scrq, $sec,$eb); <br>
      } <br>
  catch (Exception $e)<br> 
  { <br>
      print_r($e); <br>
  } <br>
  //debug <br>
      print "Request: \n". <br>
            htmlspecialchars($soap->__getLastRequestHeaders()) ."\n"; <br>
      print "Request: \n". <br>
             htmlspecialchars($soap->__getLastRequest()) ."\n"; <br>
      print "Response: \n". <br>
             $soap->__getLastResponseHeaders()."\n"; <br>
      print "Response: \n". <br>
             $soap->__getLastResponse()."\n"; <br>
  <br>
  print_r($omg); <br>
  //the first envelope headers <br>
  class EbXmlMessage <br>
  { <br>
      public $From = array('PartyId' => 'mysite.com'); <br>
      public $To = array('PartyId' => 'myprovider.com');<br> 
      public $CPAId = 'ZZZZ'; <br>
      public $ConversationId = 'myconv@id.com'; <br>
      public $Service = 'Session';// or SessionCreate?<br>
      public $Action = 'SessionCreateRQ'; <br>
      public $MessageData = array(
          'MessageId' => 'messageid', 
          'Timestamp' => '2009-04-18T15:15:00Z');<br>
       <br><br>
  } <br>
  //the security token <br>
  class Security { <br>
      public $Username = "xxxxx"; <br>
      public $Password = "yyyyy"; <br>
      public $Organization = "ZZZZ"; <br>
      public $Domain = "DEFAULT"; <br>
  } <br>
  //this is suppoused to be the payload, or the xml i need to send at the end <br>
  class SessionCreateRQ <br>
  { <br>
      public $POS = array( <br>
              'Source' => array( <br>
                  '_'=>"", <br>
                  'PseudoCityCode'=>'ZZZZ' <br>
              )); <br>
  } <br>
  <br>
  </code>
  <br>
  I keep getting the following error:</p>
  
  <p>Response: 
  HTTP/1.1 500 Internal Server Error
  SOAPAction: ""
  Content-Type: text/xml;charset=utf-8
  Date: Sun, 19 Apr 2009 22:21:34 GMT
  Connection: close
  Server: SWS</p>
  
  <p>Response: </p>
  
  <blockquote>
    <p>soap-env:Client.InvalidEbXmlMessageUnable to internalize
    messagejavax.xml.soap.SOAPException: Unable to internalize message    at
    com.sun.xml.messaging.saaj.soap.MessageImpl.(MessageImpl.java:135)
      at
    com.sun.xml.messaging.saaj.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:32)
      at
    com.sabre.universalservices.gateway.control.SoapProcessor.getRequest(SoapProcessor.java:263)
      at
    com.sabre.universalservices.gateway.control.WSGateway.handleRequest(WSGateway.java:380)
      at
    com.sabre.universalservices.gateway.control.WSGateway.doPost(WSGateway.java:306)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)     at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)  at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
      at
    org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:852)
      at
    org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:584)
      at
    org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
      at java.lang.Thread.run(Thread.java:595) Caused by:
    javax.xml.soap.SOAPException: Invalid
    Content-Type:application/soap+xml     at
    com.sun.xml.messaging.saaj.soap.MessageImpl.verify(MessageImpl.java:159)
      at
    com.sun.xml.messaging.saaj.soap.MessageImpl.(MessageImpl.java:91)
      ... 19 more</p>
    
    <p>SoapFault Object (
        [message:protected] => Unable to internalize message
        [string:private] =>  .....</p>
  </blockquote>
  
  <p>This service should be validating me on the system and returning a security object to be used in later calls - a string(?) which I can then store in a session variable for the following calls.</p>
  
  <p>Any help GREATLY appreciated!!!</p>