简体   繁体   English

使用PHP和Soap连接到Web服务

[英]connecting to webservice Using PHP & Soap

ok I'm trying to connect to a webservice which utilizes the OTA XML schema (" http://www.opentravel.org/OTA/2003/05/GetVehAvailRate ") 好的,我尝试连接到使用OTA XML架构的Web服务(“ http://www.opentravel.org/OTA/2003/05/GetVehAvailRate ”)

this webservice is hosted at rentcentric.com, which is a hosted solution for taking reservations and bookings online, the system requires a username and password to connect & so far every attempt at connecting has resulted in a blank white page. 该Web服务托管在rentcentric.com上,这是一个用于在线进行预订和预订的托管解决方案,系统需要用户名和密码才能进行连接,到目前为止,每次连接尝试都导致白页空白。

no error messages no PHP output, 没有错误消息,没有PHP输出,

Im still fairly new to using SOAP, (although I did have great success when using it on an estate agents site - which didnt require any authentication just a simple value to identify the company on that service) 进出口仍然相当新的使用SOAP,(虽然我没有使用上的地产代理网站时,它有巨大的成功-这didnt需要任何身份验证,只是一个简单的值,以确定对服务公司)

I have read and tried nearly all the examples found on this site & others with no joy! 我已经阅读并尝试了几乎所有在本网站以及其他网站上发现的所有示例,没有任何喜悦!

the request made to the service is outlined below, each request has a core set of arguments which are: 对该服务的请求概述如下,每个请求都有一组核心参数,它们是:

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

the service url http://www2.rentcentric.com/Ota2007a/OTASrvc.asmx has all the methods available to us. 服务网址http://www2.rentcentric.com/Ota2007a/OTASrvc.asmx提供了所有可用的方法。

# GetVehAvailRate
# VehCancel
# VehLocSearch
# VehModify
# VehRes 

Request -: GetVehAvailRate 请求-: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>............

code example: 代码示例:

$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));

Im just bangning my head against the wall trying to get something to return, All I need is pointed in the right direction... 我只是把头撞在墙上,试图得到一些回报,我所需要的只是指向正确的方向...

Look at the documentation here: 在这里查看文档:

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

to see how to add the trace variable to your SoapClient constructor. 了解如何将跟踪变量添加到您的SoapClient构造函数。 Once you've done that you can use 完成后,您可以使用

  • SoapClient::__getLastRequestHeaders SoapClient :: __ getLastRequestHeaders
  • SoapClient::__getLastRequest SoapClient :: __ getLastRequest
  • SoapClient::__getLastResponse SoapClient :: __ getLastResponse
  • SoapClient::__getLastResponseHeaders SoapClient :: __ getLastResponseHeaders

As a means to, at the very least, get some feedback as to why your calls are failing. 至少可以从中获得一些有关您的呼叫失败原因的反馈。

You can try using another soap implementation and see if the problem persists. 您可以尝试使用其他soap实现,然后查看问题是否仍然存在。 I suggest you Zend Soap 我建议你Zend Soap

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

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