[英]Get element from WSDL in PHP using Soap
i need to make a soap php to get coupons from https://planetwin365.com/Controls/CouponWS.asmx?wsdl 我需要制作一个肥皂PHP来从https://planetwin365.com/Controls/CouponWS.asmx?wsdl获取优惠券
The WSDL in question is Planetwin365 . 有问题的WSDL是Planetwin365。 The snippet in question looks something like this:
有问题的代码段看起来像这样:
<wsdl:service name="CouponWS">
<wsdl:port name="CouponWSSoap" binding="tns:CouponWSSoap">
<soap:address location="http://planetwin365.com/Controls/CouponWS.asmx"/>
</wsdl:port>
<wsdl:port name="CouponWSSoap12" binding="tns:CouponWSSoap12">
<soap12:address location="http://planetwin365.com/Controls/CouponWS.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I'm currently doing this: 我目前正在这样做:
$xml = new DOMDocument();
$xml->load($this->wsdl);
$version = $xml->getElementsByService('CouponWS')->item(0)->nodeValue;
he didn't work 他没工作
To create a soap client you do this: 要创建肥皂客户端,请执行以下操作:
$client = new SoapClient("https://planetwin365.com/Controls/CouponWS.asmx?wsdl");
You didn't say exactly which method you wanted to execute. 您没有确切说明要执行的方法。 There is a number of coupon related methods you can choose.
您可以选择多种与优惠券相关的方法。 You can list them out doing this:
您可以这样做列出他们:
var_dump($client->__getFunctions());
Which returns a number of operations you can perform: 它返回您可以执行的许多操作:
GetSaldoResponse GetSaldo(GetSaldo $parameters)
GetDisbilitazioneGirocontiResponse GetDisbilitazioneGiroconti(GetDisbilitazioneGiroconti $parameters)
GetStatoCouponResponse GetStatoCoupon(GetStatoCoupon $parameters)
CouponPromozioneOKResponse CouponPromozioneOK(CouponPromozioneOK $parameters)
GetStatoCouponAsincronoResponse GetStatoCouponAsincrono(GetStatoCouponAsincrono $parameters)
GetSaldoResponse GetSaldo(GetSaldo $parameters)
GetDisbilitazioneGirocontiResponse GetDisbilitazioneGiroconti(GetDisbilitazioneGiroconti $parameters)
GetStatoCouponResponse GetStatoCoupon(GetStatoCoupon $parameters)
CouponPromozioneOKResponse CouponPromozioneOK(CouponPromozioneOK $parameters)
GetStatoCouponAsincronoResponse GetStatoCouponAsincrono(GetStatoCouponAsincrono $parameters)
Choose the one you want to call. 选择您要呼叫的那个。 For example, let's take a look at
GetStatoCoupon()
. 例如,让我们看一下
GetStatoCoupon()
。 We can see that this method takes one parameter called $parameters
and it is a GetStatoCoupon
type structure. 我们可以看到此方法采用一个称为
$parameters
并且它是一个GetStatoCoupon
类型的结构。 The method returns a GetStatoCouponResponse
. 该方法返回一个
GetStatoCouponResponse
。
What does the GetStatoCoupon
type look like? GetStatoCoupon
类型是什么样的? To find out do: 要找出来做:
var_dump($client->__getTypes());
And we can see that GetStatoCoupon looks like: 我们可以看到GetStatoCoupon看起来像:
[4]=>
string(40) "struct GetStatoCoupon {
int IDCoupon;
}"
We now have enough information to construct a basic call: 现在,我们有足够的信息来构建基本调用:
$client = new SoapClient("https://planetwin365.com/Controls/CouponWS.asmx?wsdl");
$parameters = new StdClass();
$parameters->IDCoupon = 1234;
$response = $client->GetStatoCoupon($parameters);
My call results in an error because I don't know what values can go into IDCoupon
, but hopefully this answers your question on how to create a SOAP client to get coupons. 我的通话导致错误,因为我不知道
IDCoupon
可以包含哪些值,但是希望这可以回答您有关如何创建SOAP客户端以获取优惠券的问题。
我强烈建议您使用WSDL到php生成器,以从PackageGenerator获得易于使用的SDK / soap客户端
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.