帮助在PHP中创建soap请求

时间:2011-05-24 06:56:49

标签: php soap

我将如何为这样的结构创建一个数组

很抱歉,但我知道如何发送一个soap请求[php.net] ..我只想确认我需要使用自定义属性生成此类请求的数组结构

<?xml version="1.0" encoding="utf-8"?>

   <SOAP-ENV:Header>

          <m:AuthenticationInfo xmlns:m="https://xml.hotelclub.net/xmlws/services/v2/">

                 <m:AffiliateID>xxx</m:AffiliateID>

                 <m:Password>xxx</m:Password>

                 <m:ClientIP>xxx</m:ClientIP>

          </m:AuthenticationInfo>

   </SOAP-ENV:Header>

   <SOAP-ENV:Body>

          <m:HotelBookingRequest xmlns:m="https://xml.hotelclub.net/xmlws/services/v2/" Version="2" LanguageCode="EN" CurrencyCode="AUD" AffiliateUniqueID="Rodel9">

                 <m:StayDateRange CheckIn="2011-03-28" CheckOut="2011-03-29" ArrivalTime="12"/>

                 <m:Hotel ID="54"></m:Hotel>

                 <m:ItemsRequest>

                       <m:ItemRequest Type="Room" QuantityRequired="1"

                                                   NumberOfAdults="1"

                                                   NumberOfChildren="0"

                                                   Code="117;54;45877">

                              <m:Guests>

                                     <m:Guest IsChild="false">

                                            <m:FirstName>Rodel</m:FirstName>

                                            <m:LastName>Surat</m:LastName>

                                     </m:Guest>

                              </m:Guests>

                       </m:ItemRequest>

                 </m:ItemsRequest>

                 <m:GuestRequest SmokingPreference="NoPreference" BabyCot="false" LateCheckIn="false"></m:GuestRequest>

                 <m:MainGuest IsMainGuest="true" IsChild="false">

                       <m:FirstName>Rodel</m:FirstName>

                       <m:LastName>Surat</m:LastName>

                       <m:Address>

                              <m:Country ID="3"/>

                              <m:Telephone>123456789</m:Telephone>

                       </m:Address>

                       <m:EmailAddress>rodel.surat@hotelclub.com</m:EmailAddress>

                 </m:MainGuest>

                 <m:PaymentDetail ItineraryTotalAmount="520">

                       <m:CreditCardDetail SerialCode="XXX" CardType="VSA" CardNumber=" XXXXXXXXXXXXXXXX" ExpiryDate="0811">

                              <m:CardHolderName>Rodel Surat</m:CardHolderName>

                              <m:Address>

                                     <m:AddressLine>680 George St</m:AddressLine>

                    <m:City Name="Sydney" />

                                     <m:State>NSW</m:State>

                    <m:Country ID="3" />

                    <m:Postcode>2000</m:Postcode>

                              </m:Address>

                       </m:CreditCardDetail>

                 </m:PaymentDetail>

  </m:HotelBookingRequest>

   </SOAP-ENV:Body>

 然后将其作为肥皂请求发送。我是PHP中的SOAP新手

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

这是一个简单的wcf服务测试,我把它放在一起

/* Default location of WSDL Service (if used) */
define("DEFAULT_WSDL", "http://yourserver.com/Yoursvc.svc?wsdl");

/* Misc WSDL settings */
define("WSDL_SOAP_VERSION", SOAP_1_1);
define("WSDL_EXCEPTIONS", true);
define("WSDL_TRACE", 1);


/** Methods below **/
function testWcf() {

    try {
        $wsdloptions = array(
            'soap_version' => constant('WSDL_SOAP_VERSION'),
            'exceptions' => constant('WSDL_EXCEPTIONS'),
            'trace' => constant('WSDL_TRACE')
        );

        $client = new SoapClient(constant('DEFAULT_WSDL'), $wsdloptions);

        pr($client->__getFunctions());
        pr($client->__getTypes());
    } catch (Exception $exc) {
        echo $exc->getTraceAsString();
    }
}

function pr($array) {
    echo "<xmp>";
    print_r($array);
    echo "</xmp>";
}

希望它能帮助你前进。