繁体   English   中英

使用PHP和Soap连接到Web服务

[英]connecting to webservice Using PHP & Soap

好的,我尝试连接到使用OTA XML架构的Web服务(“ http://www.opentravel.org/OTA/2003/05/GetVehAvailRate ”)

该Web服务托管在rentcentric.com上,这是一个用于在线进行预订和预订的托管解决方案,系统需要用户名和密码才能进行连接,到目前为止,每次连接尝试都导致白页空白。

没有错误消息,没有PHP输出,

进出口仍然相当新的使用SOAP,(虽然我没有使用上的地产代理网站时,它有巨大的成功-这didnt需要任何身份验证,只是一个简单的值,以确定对服务公司)

我已经阅读并尝试了几乎所有在本网站以及其他网站上发现的所有示例,没有任何喜悦!

对该服务的请求概述如下,每个请求都有一组核心参数,它们是:

PickUpDateTime //date
ReturnDateTime //date
PickUpLocation.locationCode //string
ReturnLocation.locationCode //string
PromotionCod //string

服务网址http://www2.rentcentric.com/Ota2007a/OTASrvc.asmx提供了所有可用的方法。

# GetVehAvailRate
# VehCancel
# VehLocSearch
# VehModify
# VehRes 

请求-:GetVehAvailRate

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SRVCredentials xmlns="http://www.opentravel.org/OTA/2003/05">
      <Username>*USERNAME*</Username>
      <Password>*PASSWORD*</Password>
    </SRVCredentials>
  </soap:Header>
  <soap:Body>
    <OTA_VehAvailRateRQ EchoToken="string" TimeStamp="dateTime" Target="Test or Production" Version="decimal" TransactionIdentifier="string" SequenceNmbr="nonNegativeInteger" TransactionStatusCode="Start or End or Rollback or InSeries or Continuation or Subsequent" PrimaryLangID="language" AltLangID="language" RetransmissionIndicator="boolean" ReqRespVersion="string" MaxResponses="positiveInteger" MaxPerVendorInd="boolean" xmlns="http://www.opentravel.org/OTA/2003/05">
      <POS>............

代码示例:

$soapClient = new SoapClient("http://www2.rentcentric.com/Ota2007a/OTASrvc.asmx?wsdl");

    // Prepare SoapHeader parameters
    $sh_param = array(
             'Username'=>'username',
             'Password'=>'password');
    $headers = new SoapHeader('http://www2.rentcentric.com/Ota2007a/', 'UserCredentials', $sh_param);

        // Prepare Soap Client
        $soapClient->__setSoapHeaders(array($headers));

我只是把头撞在墙上,试图得到一些回报,我所需要的只是指向正确的方向...

在这里查看文档:

http://www.php.net/manual/zh/soapclient.soapclient.php

了解如何将跟踪变量添加到您的SoapClient构造函数。 完成后,您可以使用

  • SoapClient :: __ getLastRequestHeaders
  • SoapClient :: __ getLastRequest
  • SoapClient :: __ getLastResponse
  • SoapClient :: __ getLastResponseHeaders

至少可以从中获得一些有关您的呼叫失败原因的反馈。

您可以尝试使用其他soap实现,然后查看问题是否仍然存在。 我建议你Zend Soap

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM