如何在我的Codeigniter Soap服务器代码中声明多个功能?

迪彭

我也试图将函数声明为普通函数,但没有解决我的问题。我能够使用许多教程中的单个功能运行服务器代码,但是无法添加多个功能。请给我建议我该怎么做。

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Support extends CI_Controller {
public $ns="";

function __construct()
{

    parent::__construct();

    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';

    $this->load->library("nusoap_library");
    $this->load->model('support_model');

    $this->nusoap_server = new soap_server();

    $this->ns = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/soapserver/';
    //$ns ="urn:server";

    $this->nusoap_server->configureWSDL("SupportWsdl", $this->ns); // wsdl cinfiguration
    $this->nusoap_server->wsdl->schemaTargetNamespace = $this->ns; // server namespace


    //first simple function
    $this->nusoap_server->register('hello',
        array('username' => 'xsd:string'),  //parameter
        array('return' => 'xsd:string'),  //output
        'urn:server',   //namespace
        'urn:'.$this->ns.'helloServer',  //soapaction
        'rpc', // style
        'encoded', // use
        'Just say hello');  //description

    //this is the second webservice entry point/function 
    $this->nusoap_server->register('login',
        array('username' => 'xsd:string', 'password'=>'xsd:string'),  //parameters
        array('return' => 'tns:Person'),  //output
        'urn:server',   //namespace
        'urn:'.$this->ns.'loginServer',  //soapaction
        'rpc', // style
        'encoded', // use
        'Check user login');  //description

       //first function implementation
    function hello() {
        function hello($username){
            $this->nusoap_server->service($HTTP_RAW_POST_DATA);
            return 'Howdy, '.$username.'!';  
        }    
    }

    //second function implementation 
    function login($username, $password) {
            //should do some database query here
            //just some dummy result
            return array(
            'id_user'=>1,
            'fullname'=>'John Reese',
            'email'=>'[email protected]',
            'level'=>99
        );
        // $this->nusoap_server->service($HTTP_RAW_POST_DATA);
    }     
}



function index()
{
    $this->nusoap_server->service(file_get_contents("php://input"));// read raw data from request body
}

}

迪彭

我发现我们应该在索引函数中声明我们所有的soap函数。而不是声明类函数。如果有人知道如何定义寄存器类函数,请演示如何执行。我的肥皂服务器端代码

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Support extends CI_Controller {
public $ns="";

function __construct()
{

    parent::__construct();

    $this->load->library("nusoap_library");
    $this->nusoap_server = new soap_server();

    $this->ns = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/soapserver/';

    $this->nusoap_server->configureWSDL("SupportWsdl", $this->ns); // wsdl cinfiguration
    $this->nusoap_server->wsdl->schemaTargetNamespace = $this->ns; // server namespace

     //first simple function
    $this->nusoap_server->register('hello',
        array('username' => 'xsd:string'),  //parameter
        array('return' => 'xsd:string'),  //output
        'urn:server',   //namespace
        'urn:'.$this->ns.'hello',  //soapaction
        'rpc', // style
        'encoded', // use
        'Just say hello');  //description

    $this->nusoap_server->register('bye',
        array('username' => 'xsd:string'),  //parameter
        array('return' => 'xsd:string'),  //output
        'urn:server',   //namespace
        'urn:'.$this->ns.'bye',  //soapaction
        'rpc', // style
        'encoded', // use
        'Just say bye');  //    

}

function index()
{
       function hello($username){
        //$this->nusoap_server->service($HTTP_RAW_POST_DATA);
        return 'Howdy, '.$username.'!';  
    } 


 function bye($username){
        //$this->nusoap_server->service($HTTP_RAW_POST_DATA);
        return 'bye, '.$username.'!';  
    } 
    $this->nusoap_server->service(file_get_contents("php://input"));// read raw data from request body
}    
}

我的客户端代码

class Attendance extends MX_Controller {
public $data = array();
private $permission = array();
private $branch = array();

function __construct(){
    parent::__construct();

    //This is your webservice server WSDL URL address
    $wsdl = "http://localhost/SOAP_Final/index.php/support?wsdl";

    $this->load->library("nusoap_library");
    $this->nusoap_server = new soap_server(); 

}


public function index()
{  

}



function call_hello()
{
    $this->nusoap_client = new nusoap_client("http://localhost/SoapFinalVersion/index.php/support?wsdl");

    if($this->nusoap_client->fault)
    {
         $text = 'Error: '.$this->nusoap_client->fault;
         echo "Hello ";
    }
    else
    {
        if ($this->nusoap_client->getError())
        {
             $text = 'Error: '.$this->nusoap_client->getError();
             echo "Hello ";
        }
        else
        {   
             $row = $this->nusoap_client->call(
                      'hello',
                      array('username'=>'john')
                    );       
              var_dump($row);      
        }
    }
}
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

我应该如何在Codeigniter中布置代码?

来自分类Dev

如何在Codeigniter for Rest服务器中配置路由?

来自分类Dev

如何在服务器中托管Codeigniter?

来自分类Dev

如何在Codeigniter for Rest服务器中配置路由?

来自分类Dev

我如何在根目录外部的Codeigniter中显示图像

来自分类Dev

如何在codeigniter中重定向到我的指定页面

来自分类Dev

如何在codeigniter base_url中显示我的图像

来自分类Dev

我无法在解析服务器中的云代码功能中访问响应对象?

来自分类Dev

我如何在Java中停止我的服务器

来自分类Dev

如何使用空手道在模拟服务器中合并多个功能文件?

来自分类Dev

如何在 Firebase 中编写后端服务器代码

来自分类Dev

如何在ubuntu服务器中配置多个代理

来自分类Dev

如何在客户端中存储Web服务器的多个服务器地址?

来自分类Dev

如何在我的 ubuntu 服务器中运行 .cpp?

来自分类Dev

当我以不存在的路线访问Class时,如何在codeIgniter中设置默认功能?

来自分类Dev

如何修复我的POST功能代码可以与服务器通信?

来自分类Dev

如何在服务器中的codeigniter中删除“ index.php”

来自分类Dev

如何在codeigniter中将我的上传功能转换为Helper?

来自分类Dev

Codeigniter:如何在我的项目中使用多个“ MY_Model”?

来自分类Dev

如何在我们的项目中应用codeigniter文件上传器?

来自分类Dev

如何在Codeigniter中使我的购物车项目计数器为ajax?

来自分类Dev

我如何在CodeIgniter中调用核心文件夹中已存在的文件

来自分类Dev

如何在 SOA 企业管理器中运行 SOAP Web 服务的多个实例?

来自分类Dev

如何在codeigniter中创建搜索功能

来自分类Dev

如何查找我正在使用的DNS服务器(在多个已配置的dns服务器中)

来自分类Dev

如何在我的视图文件中显示每个用户ID的记录数:Codeigniter

来自分类Dev

如何在我的应用程序URL中传递ID“ 0”?(CodeIgniter)

来自分类Dev

我有帖子ID,评论ID,如何在CodeIgniter中获取单个评论ID

来自分类Dev

我如何在Codeigniter中使用stdclass调用类中的函数

Related 相关文章

  1. 1

    我应该如何在Codeigniter中布置代码?

  2. 2

    如何在Codeigniter for Rest服务器中配置路由?

  3. 3

    如何在服务器中托管Codeigniter?

  4. 4

    如何在Codeigniter for Rest服务器中配置路由?

  5. 5

    我如何在根目录外部的Codeigniter中显示图像

  6. 6

    如何在codeigniter中重定向到我的指定页面

  7. 7

    如何在codeigniter base_url中显示我的图像

  8. 8

    我无法在解析服务器中的云代码功能中访问响应对象?

  9. 9

    我如何在Java中停止我的服务器

  10. 10

    如何使用空手道在模拟服务器中合并多个功能文件?

  11. 11

    如何在 Firebase 中编写后端服务器代码

  12. 12

    如何在ubuntu服务器中配置多个代理

  13. 13

    如何在客户端中存储Web服务器的多个服务器地址?

  14. 14

    如何在我的 ubuntu 服务器中运行 .cpp?

  15. 15

    当我以不存在的路线访问Class时,如何在codeIgniter中设置默认功能?

  16. 16

    如何修复我的POST功能代码可以与服务器通信?

  17. 17

    如何在服务器中的codeigniter中删除“ index.php”

  18. 18

    如何在codeigniter中将我的上传功能转换为Helper?

  19. 19

    Codeigniter:如何在我的项目中使用多个“ MY_Model”?

  20. 20

    如何在我们的项目中应用codeigniter文件上传器?

  21. 21

    如何在Codeigniter中使我的购物车项目计数器为ajax?

  22. 22

    我如何在CodeIgniter中调用核心文件夹中已存在的文件

  23. 23

    如何在 SOA 企业管理器中运行 SOAP Web 服务的多个实例?

  24. 24

    如何在codeigniter中创建搜索功能

  25. 25

    如何查找我正在使用的DNS服务器(在多个已配置的dns服务器中)

  26. 26

    如何在我的视图文件中显示每个用户ID的记录数:Codeigniter

  27. 27

    如何在我的应用程序URL中传递ID“ 0”?(CodeIgniter)

  28. 28

    我有帖子ID,评论ID,如何在CodeIgniter中获取单个评论ID

  29. 29

    我如何在Codeigniter中使用stdclass调用类中的函数

热门标签

归档