如何在php中使用soap发送xml请求? [英] how to send xml request using soap in php?

查看:60
本文介绍了如何在php中使用soap发送xml请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发新项目,对于这个项目,我必须使用 SOAP.我是这个 SOAP 的新手.我红了我的项目文档.在该文档中,它具有 WSDL 和 XML 请求.通过使用boath WSDL 和XML 请求,我如何发送XML 请求.波纹管我正在编写 WSDL 和 XML 请求.请帮帮我.

I am working on new project, for this project i have to use SOAP. I am new to this SOAP. I red my project documentation. In that documentation it has WSDL and XML request. By using boath WSDL and XML request how can i send XML request. Bellow i am writing WSDL and XML request. Please help me.

谢谢.

WSDL:

http://acceptance.travelstreet.com/hotelsv3/components/hotels_ws.cfc?wsdl

XML 请求:

<?xml version="1.0" encoding="utf-8"?>
<OTA_HotelAvailRQ Version="1.0">
   <POS>
    <Source>
     <UniqueId Id="username:password" />
    </Source>
   </POS>
   <AvailRequestSegments>
    <AvailRequestSegment>
     <StayDateRange End="2011-08-15" Start="2011-08-14" />
     <RoomStayCandidates>
      <RoomStayCandidate Quantity="1">
       <GuestCounts>
        <GuestCount AgeQualifyingCode="10" Count="1" />
       </GuestCounts>
      </RoomStayCandidate>
     </RoomStayCandidates>
     <HotelSearchCriteria>
      <Criterion>
       <HotelRef Destination="East London, South Africa" CityCode="" CountryCode="" HotelName="" MinHotelRating="1"/>
       <SearchCurrency>EUR</SearchCurrency>
       <AdditionalInfo Value="1" />
       <Language>EN</Language>
      </Criterion>
     </HotelSearchCriteria>
    </AvailRequestSegment>
   </AvailRequestSegments>
  </OTA_HotelAvailRQ>

推荐答案

我建议你阅读有关 PHP 的内容肥皂客户端.PHP 手册中有很多很好的例子.

I suggest you read up about PHP's SoapClient. There are lots of good examples in the PHP manual.

为了让您开始,请创建对象:

To get you started, create the object:

$client = new SoapClient('http://www.example.com/end_point.wsdl');

然后调用方法:

$result = $client->SomeFunction($data);

其中 SomeFunction 是您要在服务上调用的方法名称,$data 是一个 PHP 数组,表示您要发送的 XML 数据结构.

where SomeFunction is the method name you want to call on the service, and $data is a PHP array representing the XML data structure you want to send.

希望有所帮助.

只是为了根据 OP 的进一步问题进行澄清:

Just to clarify in light of the OP's further questions:

在使用 PHP SOAPClient 时,您不需要创建实际的 XML 代码.您需要将数据放入一个 PHP 数组中,SOAPClient 会为您将其转换为 XML.数组键应以 XML 元素名称命名,数组值是元素值.对嵌套的 XML 元素使用嵌套数组.

You don't need to create the actual XML code when using PHP SOAPClient. You need to put the data into a PHP array, and SOAPClient will convert it to XML for you. The array keys should be named for the XML element names, and the array values are the element values. Use nested arrays for nested XML elements.

这篇关于如何在php中使用soap发送xml请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆