Hello everyone
I'm trying to develop an app that consumes certain Webservices which are served via SOAP.
However I feel like PHP SOAP documentation is not enough for unexperienced people like me. I've done a really extensive reasearch on google and found some solutions but I just can't get them to work right
I need to generate and send this SOAP call in order to execute the SessionCreateRQ call i need to
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:eb="http://www.ebxml.org/namespaces/messageHeader"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header>
<eb:MessageHeader SOAP-ENV:mustUnderstand="1" eb:version="2.0">
<eb:ConversationId>ABC123@clientURL.com</eb:ConversationId>
<eb:From>
<eb:PartyId type="urn:x12.org:IO5:01">clientURL</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId type="urn:x12.org:IO5:01">webservices.company.com</eb:PartyId>
</eb:To>
<eb:CPAId>yourIPCC</eb:CPAId>
<eb:Service eb:type="sabreXML">Session</eb:Service>
<eb:Action>SessionCreateRQ</eb:Action>
<eb:MessageData>
<eb:MessageId>mid:20031209-133003-2333@clientURL</eb:MessageId>
<eb:Timestamp>2003-12-09T11:15:12Z</eb:Timestamp>
<eb:TimeToLive>2003-12-09T11:15:12Z</eb:TimeToLive>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/12/utility">
<wsse:UsernameToken>
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password>PASSWORD</wsse:Password>
<Organization>yourIPCC</Organization>
<Domain>DEFAULT</Domain>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<eb:Manifest SOAP-ENV:mustUnderstand="1" eb:version="2.0">
<eb:Reference xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="cid:SessionCreateRQ" xlink:type="simple"/>
</eb:Manifest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SessionCreateRQ>
<POS>
<Source PseudoCityCode="yourIPCC"/>
</POS>
</SessionCreateRQ>
Note that the last XML is the payload for the request , to generate this petition im trying to reach the objective by using class maps, however I don't understand how to generate the usernametoken either how to tell SOAP that certain class is the security token etc.. Im using a WSDL and the following PHP code
<?php
$soap = new SoapClient('http://mysite.com/url/to/my.wsdl',
array(
'trace' => true,
'soap_version' => SOAP_1_2,
"exceptions" => 0));
$eb = new EbXmlMessage();
$sec = new Security();
$scrq = new SessionCreateRQ();
try {
$omg = $soap->SessionCreateRQ($scrq, $sec,$eb);
}
catch (Exception $e)
{
//lets see the error
echo "<pre>";
print_r($e);
echo "</pre>";
}
//debug
echo "<pre>";
print "Request: \n".
htmlspecialchars($soap->__getLastRequestHeaders()) ."\n";
print "Request: \n".
htmlspecialchars($soap->__getLastRequest()) ."\n";
print "Response: \n".
$soap->__getLastResponseHeaders()."\n";
print "Response: \n".
$soap->__getLastResponse()."\n";
echo "</pre>";
echo "<pre>";
print_r($omg);
echo "</pre>";
//the first envelope headers
class EbXmlMessage
{
public $From = array('PartyId' => 'mysite.com');
public $To = array('PartyId' => 'myprovider.com');
public $CPAId = 'cpaid';
public $ConversationId = 'myconv@id.com';
public $Service = 'Session';
public $Action = 'SessionCreateRQ';
public $MessageData = array(
'MessageId' => 'messageid',
'Timestamp' => '2009-04-09T05:15:00Z');
}
//the security token
class Security {
public $Username = "username";
public $Password = "pass";
public $Organization = "org";
public $Domain = "mydomain";
}
//this is suppoused to be the payload, or the xml i need tos end at the en
class SessionCreateRQ
{
public $POS = array(
'Source' => array(
'_'=>"",
'PseudoCityCode'=>'codeee'
));
}
?>
thanks in advance