繁体   English   中英

xml,soap和php

[英]xml, soap and php

我需要使用Soap和php发送xml请求。 我想要的xml requet是这样的

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
    <soapenv:Header/>
    <soapenv:Body>
        <air:AirFareRulesReq AuthorizedBy="TESTANTON" TargetBranch="P7001111" FareRuleType="long" xmlns:air="http://www.travelport.com/schema/
air_v20_0" xmlns:com="http://www.travelport.com/schema/common_v17_0">
            <com:BillingPointOfSaleInfo OriginApplication="UAPI" />
            <air:FareRuleKey FareInfoRef="14T" ProviderCode="1G">
            </air:FareRuleKey>
        </air:AirFareRulesReq>
    </soapenv:Body>
</soapenv:Envelope>

我为此编写的php cod是

创建属性数组

$fareopta = array();
$fareopta["BillingPointOfSaleInfo"]= array();
$fareopta["BillingPointOfSaleInfo"]["OriginApplication"]= "UAPI";
$fareopta["AirReservationSelector"] = array();
$fareopta["FareRuleLookup"]=array();
$fareopta["FareRuleKey"] = array();
$fareopta["AirPricingSolution"] = array();
$fareopta["FareRuleKey"]["FareInfoRef"] = $_GET['pricingKey'];
$fareopta["FareRuleKey"]["ProviderCode"] = "1G";

调用函数的代码

$client = new FareruleSoapClient(
    MY_ABSOLUTE_DIRECTORY . 
    "/uAPI_WSDLschema_Release-11.2.02-v11.2/air_v16_0/Air.wsdl"
);

$fareresult = $client->service($fareopta);

// code for FareruleSoapClient class

class FarerulesSoapClient extends SoapClient 
{

    function __construct($wsdlLocation)
    {   
        $trac["trace"]=1;
        $trac["use"]=SOAP_LITERAL;
        $trac["style"]=SOAP_DOCUMENT;
        $trac["compression"]=SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5;
        //$trac["compression"]=SOAP_COMPRESSION_ACCEPT ;
        $trac["type_ns"]="";

        $trac["login"]=SOAP_CLIENT_USERNAME;
        $trac["password"]=SOAP_CLIENT_PASSWORD;
        $trac["location"]="https://emea.copy-webservices.travelport.com/B2BGateway/connect/uAPI/AirFareRulesService";
        $trac["action"]="http://localhost:8080/kestrel/AirFareRulesService";
        $trac["version"]="SOAP_1_1";

        parent::__construct($wsdlLocation, $trac);
    }

    function __doRequest($request, $location, $action, $version) 
    {

        $namespace1='"http://www.travelport.com/schema/air_v15_0"';
        $namespace2='"http://www.travelport.com/schema/common_v12_0"';
        $namespace3='"http://www.travelport.com/schema/common_v13_0"';

        $request=str_replace("<ns2:AirFareRulesReq","<ns2:AirFareRulesReq"." ".'TargetBranch="P107616"'." "."xmlns:ns2=".$namespace1,$request);

         return parent::__doRequest($request, $location, $action, $version);

        echo parent::__getLastRequest();
        echo parent::__getLastResponse();
    } 

    function __getLastRequest()
    {
        return parent::__getLastRequest();
    }
}

但是,每当我运行代码时,xml请求都将成为另一个名为AirRepriceReq请求的请求。 我认为这是因为AirRepriceReq和AirFareRuleReq使用相同的服务。 代码中提到的($ fareresult = $ client-> service($ fareopta);)。

我应该怎么做才能避免这种过度使用?

我通过在创建SoapClient对象之前修改(限制)我的代码中的.wsdl文件来绕过此问题。

暂无
暂无

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

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