Re: SOAP server, how to

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[code]
<?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);
?>
[/code]

and the rest of my problem is, how to insert 'some data' into complex types
i created, i have try this
[code]
return array(
  'success'=>'success',
  'RoomTypeCode'=>'SGL',
  'Name'=>'single room'
 );   
[/code]
but it won't work, and the SOAP response is :
[code]
<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>
[/code]

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 
[CODE]
<AvailRequestSegment AvailReqType="Room">
[/CODE]

it's very appreciate if somebody like to help me... thanks in advance..



--
View this message in context: http://php-soap.996275.n3.nabble.com/SOAP-server-how-to-tp1446p1447.html
Sent from the Php Soap mailing list archive at Nabble.com.

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux