【问题标题】:Consume wadl service in php在 php 中使用 wadl 服务
【发布时间】:2016-04-13 07:04:31
【问题描述】:

我需要从 wadl 服务调用一个方法并传递一个参数

wadl: http://domain.com/application.wadl 
method: checkInfo 

我该怎么做?

//Wsdl - Soap: I need to do this but with a wadl service

$wsdl = new SoapClient('http://domain.com/application?wsdl');

$wsdl->__call('checkInfo',array('data'=> ''));
//or
$wsdl->checkInfo(array('data'=> ''));

谢谢!!!!

【问题讨论】:

    标签: php web-services codeigniter wadl


    【解决方案1】:

    您可以使用 SOAP 服务器来做到这一点:

    class MyClass{
        function checkInfo() {
            return "Hello";
        }
    
    }
    //when in non-wsdl mode the uri option must be specified
    $options=array('uri'=>'http://localhost/');
    //create a new SOAP server
    $server = new SoapServer(NULL,$options);
    //attach the API class to the SOAP Server
    $server->setClass('MyClass');
    //start the SOAP requests handler
    $server->handle();
    

    然后使用它:

    <?php
     /*
     * PHP SOAP - How to create a SOAP Server and a SOAP Client
     */
    
    $options = array('location' => 'http://localhost/server.php', 
                      'uri' => 'http://localhost/');
    //create an instante of the SOAPClient (the API will be available)
    $api = new SoapClient(NULL, $options);
    //call an API method
    echo $api->checkInfo();
     ?>
    

    来自here的代码示例

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-15
      • 1970-01-01
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多