vidihermes Posted September 10, 2013 Share Posted September 10, 2013 Hi Fellows, I am new to SOAP or any webservices technology, but i have a project to connect an online travel agent (OTA) website to Channel Manager called Siteminder, and here is their docs https://siteminder.atlassian.net/wiki/display/SITECONNECT/Retrieve+Rooms But unfortunately i don’t even understand what is this, how can i create a SOAP server in CI which able to produce this xml below ( precisely as written in this docs ) <OTA HotelAvailRQ Versi TimeStamp=“2005-08-01T09:30:47+02:00” EchoToken=“fb57388d” AvailRates> <AvailRequestSegments> <AvailRequestSegment AvailReqType=“Room”> <HotelSearchCriteria> <Criterion> <HotelRef HotelCode=“HOTEL1”> </Criterion> </HotelSearchCriteria> </AvailRequestSegment> </AvailRequestSegments></OTA_HotelAvailRQ> and this xml as the response of previous xml (if it submitted) <OTA HotelAvailRS Versi TimeStamp=“2005-08-01T09:30:47+02:00” EchoToken=“abc123”> <Success> <RoomStays> <RoomStay> <RoomTypes> <RoomType RoomTypeCode=“SGL”> <RoomDescription Name=“Single Room”> </RoomType> </RoomTypes> </RoomStay> <RoomStay> <RoomTypes> <RoomType RoomTypeCode=“DBX”> <RoomDescription Name=“Deluxe Double Room”> </RoomType> </RoomTypes> </RoomStay> <RoomStay> <RoomTypes> <RoomType RoomTypeCode=“DBL”> <RoomDescription Name=“Standard Double Room”> </RoomType> </RoomTypes> </RoomStay> </RoomStays></OTA_HotelAvailRS> please kinly help me, and many thanks in advance… Link to comment https://forums.phpfreaks.com/topic/282035-soap-webservice-how-to/ Share on other sites More sharing options...
vidihermes Posted September 12, 2013 Author Share Posted September 12, 2013 the problem is partially solved now. i think nuSOAP is very helpful, i write PHP code shown below, and the 'SOAP request' problem is partially solved. <?php require_once('lib/nusoap.php'); $server = new nusoap_server; $server->configureWSDL('server','http://localhost/myweb'); $server->wsdl->schemaTargetNamespace = 'http://localhost/myweb'; $server->wsdl->addComplexType( 'AvailRequestSegments', 'complexType', 'struct', 'all', '', array( 'AvailRequestSegment' => array('name' => 'AvailRequestSegment', 'type' => 'tns:AvailRequestSegment') ) ); $server->wsdl->addComplexType( 'AvailRequestSegment', 'complexType', 'struct', 'all', '', array( 'AvailReqType'=>array('name'=>'AvailReqType','type'=>'xsd:string','value'=>'Room'), 'HotelSearchCriteria' => array('name' => 'HotelSearchCriteria', 'type' => 'tns:HotelSearchCriteria') ) ); $server->wsdl->addComplexType( 'HotelSearchCriteria', 'complexType', 'struct', 'all', '', array( 'Criterion' => array('name' => 'Criterion', 'type' => 'tns:Criterion') ) ); $server->wsdl->addComplexType( 'Criterion', 'complexType', 'struct', 'all', '', array( 'HotelRef' => array('name' => 'HotelRef', 'type' => 'tns:HotelRef') ) ); $server->wsdl->addComplexType( 'HotelRef', 'complexType', 'struct', 'all', '', array( 'HotelCode' => array('name' => 'HotelCode', 'type' => 'xsd:string') ) ); /*---------------------------segment response---------------------------------------------*/ $server->wsdl->addComplexType( 'RoomStays', 'complexType', 'struct', 'all', '', array( 'RoomStay' => array('name' => 'RoomStay', 'type' => 'tns:RoomStay') ) ); $server->wsdl->addComplexType( 'RoomStay', 'complexType', 'struct', 'all', '', array( 'RoomTypes' => array('name' => 'RoomTypes', 'type' => 'tns:RoomTypes') ) ); $server->wsdl->addComplexType( 'RoomTypes', 'complexType', 'struct', 'all', '', array( 'RoomType' => array('name' => 'RoomType', 'type' => 'tns:RoomType') ) ); $server->wsdl->addComplexType( 'RoomType', 'complexType', 'struct', 'all', '', array( 'RoomTypeCode'=>array('name'=>'RoomTypeCode','type'=>'xsd:string'), 'RoomDescription' => array('name' => 'RoomDescription', 'type' => 'tns:RoomDescription') ) ); $server->wsdl->addComplexType( 'RoomDescription', 'complexType', 'struct', 'all', '', array( 'Name' => array('name' => 'Name', 'type' => 'xsd:string') ) ); $server->register('OTA_HotelAvailRQ', array('AvailRequestSegments'=>'tns:AvailRequestSegments'), array('RoomStays'=>'tns:RoomStays'), 'http://localhost/myweb', 'http://localhost/myweb#SayHello'); function OTA_HotelAvailRQ($param) { return array( 'success'=>'success', 'RoomTypeCode'=>'SGL', 'Name'=>'single room' ); } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?> and the rest of my problem is, how to insert 'some data' into complex types i created, i have try this return array( 'success'=>'success', 'RoomTypeCode'=>'SGL', 'Name'=>'single room' ); but it won't work, and the SOAP response is : <SOAP-ENV Envelope SOAP-ENV:encoding 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="http://localhost/myweb"> <SOAP-ENV:Body> <ns1:OTA_HotelAvailRQResponse xmlns:ns1="http://localhost/myweb"> <RoomStays xsi:type="tns:RoomStays"/> </ns1:OTA_HotelAvailRQResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> and finally the last thing i have to solve is, i don't know how to put AvailReqType="Room" attribute inside the < AvailRequestSegment> as shown below <AvailRequestSegment AvailReqType="Room"> it's very appreciate if somebody would like to help me... thanks in advance.. Link to comment https://forums.phpfreaks.com/topic/282035-soap-webservice-how-to/#findComment-1449186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.