簡體   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