简体   繁体   中英

xml, soap and php

I need to send an xml request using Soap and php. The xml requet i wanted is like this

<?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>

The php cod I have written for this is

Created the array of attributes

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

code for calling functions

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

But whenever I run the code, the xml request is going as anothe request called AirRepriceReq request. I think it is because both the AirRepriceReq and AirFareRuleReq using the same service. mentioned in the code ($fareresult = $client->service($fareopta);).

What should i do to avoid this overridding??

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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