WSDL functions with the same name. How to choose one?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 10:45:04

问题


I'm using a provider wsdl with SoapClient but when I use the command __getFunctions I get something like this:

method1Rsp service(method1Req $parameters)
method2Rsp service(method2Req $parameters)
method3Rsp service(method3Req $parameters)
method4Rsp service(method4Req $parameters)
method5Rsp service(method5Req $parameters)

So,I can only call the function "service()" or use __soapCall('service',$info) but I always get the "method1" schema. If I use __doRequest() I can send the method I want in a self writen xml and works fine, but it's a pity... If I send the method name in the $info array, it also uses the first method.

Question: Is there a way to call specific methods using __soapCall() or the service function, or I have to modify the wsdl?

Edit:

Here is a xml request used with __doRequest:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <LowFareSearchReq TargetBranch="" xmlns="http://www.travelport.com/schema/air_v20_0" xmlns:com="http://www.travelport.com/schema/common_v17_0">
            <com:BillingPointOfSaleInfo OriginApplication="UAPI"/>
            <SearchAirLeg>
                <SearchOrigin>
                    <CityOrAirport Code="LON" xmlns="http://www.travelport.com/schema/common_v17_0" />
                </SearchOrigin>
                <SearchDestination>
                    <CityOrAirport Code="MUC" xmlns="http://www.travelport.com/schema/common_v17_0" />
                </SearchDestination>
                <SearchDepTime PreferredTime="2013-02-10" />
                <AirLegModifiers>
                    <PreferredCabins>
                        <CabinClass Type="Economy" />
                    </PreferredCabins>
                </AirLegModifiers>
            </SearchAirLeg>
            <SearchPassenger Code="ADT" Age="30" xmlns="http://www.travelport.com/schema/common_v17_0"/>
            <AirPricingModifiers CurrencyType="EUR">
            </AirPricingModifiers>
        </LowFareSearchReq>
    </s:Body>
</s:Envelope>

The location of the webservice is http://webservicename/AirService despite the method you have to use. This works okay, but the response is also and xml string. Further more, the schemas are not updated if I change the wsdl file in a future update. Using __soapCall returns an stdClass object and gets the schemas automatically.


回答1:


I think you can call service with custom paramert (method1Req or method2Req, etc). And PHPSoap library determine necessary method itself




回答2:


Assuming you're using the internal SOAP library, I think you can call the distinct operations using the correct parameters. You can do it using internal helper class SoapParam. Lets imagine that method3req needs username and log-in parameters. If you want use it, you should have something like:

 $soap = new SoapClient( $wsdl );

 class method3req{
   public $username;
   public $password;
 }

 $m3r = new method3req();

 $m3r->username = new SoapVar( 'user', SOAP_STRING, $namespace,...);
 $m3r->password = new SoapVar( 'pwd', SOAP_STRING, $namespace,...);

 $tmp = new SoapVar( $m3r, SOAP_ENV_OBJECT, $namespace, ...);
 $soap->__soapCall( 'service', $tmp ); 

You can look for helper class SoapParam too.



来源:https://stackoverflow.com/questions/14748125/wsdl-functions-with-the-same-name-how-to-choose-one

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!