doushi3454 2016-11-12 17:51
浏览 54
已采纳

使用Soap从PHP中获取WSDL中的元素

i need to make a soap php to get coupons from https://planetwin365.com/Controls/CouponWS.asmx?wsdl

The WSDL in question is 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

  • 写回答

2条回答 默认 最新

  • dongpian6319 2017-01-15 15:25
    关注

    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(). We can see that this method takes one parameter called $parameters and it is a GetStatoCoupon type structure. The method returns a GetStatoCouponResponse.

    What does the GetStatoCoupon type look like? To find out do:

    var_dump($client->__getTypes());
    

    And we can see that GetStatoCoupon looks like:

      [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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改