[英]Get element from WSDL in PHP using Soap
我需要制作一个肥皂PHP来从https://planetwin365.com/Controls/CouponWS.asmx?wsdl获取优惠券
有问题的WSDL是Planetwin365。 有问题的代码段看起来像这样:
<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>
我目前正在这样做:
$xml = new DOMDocument();
$xml->load($this->wsdl);
$version = $xml->getElementsByService('CouponWS')->item(0)->nodeValue;
他没工作
要创建肥皂客户端,请执行以下操作:
$client = new SoapClient("https://planetwin365.com/Controls/CouponWS.asmx?wsdl");
您没有确切说明要执行的方法。 您可以选择多种与优惠券相关的方法。 您可以这样做列出他们:
var_dump($client->__getFunctions());
它返回您可以执行的许多操作:
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)
选择您要呼叫的那个。 例如,让我们看一下GetStatoCoupon()
。 我们可以看到此方法采用一个称为$parameters
并且它是一个GetStatoCoupon
类型的结构。 该方法返回一个GetStatoCouponResponse
。
GetStatoCoupon
类型是什么样的? 要找出来做:
var_dump($client->__getTypes());
我们可以看到GetStatoCoupon看起来像:
[4]=>
string(40) "struct GetStatoCoupon {
int IDCoupon;
}"
现在,我们有足够的信息来构建基本调用:
$client = new SoapClient("https://planetwin365.com/Controls/CouponWS.asmx?wsdl");
$parameters = new StdClass();
$parameters->IDCoupon = 1234;
$response = $client->GetStatoCoupon($parameters);
我的通话导致错误,因为我不知道IDCoupon
可以包含哪些值,但是希望这可以回答您有关如何创建SOAP客户端以获取优惠券的问题。
我强烈建议您使用WSDL到php生成器,以从PackageGenerator获得易于使用的SDK / soap客户端
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.