Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用nusoap注册类方法_Php_Nusoap - Fatal编程技术网

Php 使用nusoap注册类方法

Php 使用nusoap注册类方法,php,nusoap,Php,Nusoap,我有一个php类,我想使用它。我可以用register命令注册nusoap中已经存在的类方法吗 样本: 在这里,我们注册了一个在这个脚本中定义的函数。但是如果我们有一个可能在几个月前开发的类,并且我们想使用它作为使用WSDL的Web服务。有没有办法注册该类的方法,以便Nusoap创建其结构(内部方法)的WSDL 这就是我解决这个问题的方法。。。也许有人可以尝试另一种方法 [File : index.php] require_once "nuSOAP/lib/nusoap.php"; re

我有一个php类,我想使用它。我可以用register命令注册nusoap中已经存在的类方法吗

样本:

在这里,我们注册了一个在这个脚本中定义的函数。但是如果我们有一个可能在几个月前开发的类,并且我们想使用它作为使用WSDL的Web服务。有没有办法注册该类的方法,以便Nusoap创建其结构(内部方法)的WSDL


这就是我解决这个问题的方法。。。也许有人可以尝试另一种方法

[File : index.php]
require_once "nuSOAP/lib/nusoap.php";    
require_once "myClass.class.inc.php";

$namespace = "http://localhost/html/nusoap/index.php";

// create a new soap server
$server = new soap_server();

// configure our WSDL
$server->configureWSDL("Class Example");

// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;

// register the class method and the params of the method
$server->register("myClass.ShowString"                       
                 ,array('name'=>'xsd:string')
                 ,array('return'=>'xsd:string')
                 ,$namespace,false
                 ,'rpc'
                 ,'encoded'
                 ,'Sample of embedded classes...' 
                                );

//
// Get our posted data if the service is being consumed
// otherwise leave this data blank.                
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) 
                ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

// pass our posted data (or nothing) to the soap service                    
$server->service($POST_DATA);                
exit();
和类代码

[File 'myClass.class.inc.php']

class myClass{

     public function __construct(){

     }


     public function ShowString($mens){

        return "\n##Remote Class :".__CLASS__."\n##Remote Method : ".__METHOD__."\n## mSG :{$mens}";

     }

}
我还用c#创建了一个soap客户端,它正确地使用soap服务


希望这有帮助

您可以使用
getProxy()


什么意思?你能举个例子吗?我用一个例子编辑了我的问题。。。希望这能澄清我的问题。谢谢你写的你想注册某个类的方法。在您的示例中,您注册了一个全局函数。是否要注册一个类函数?只是问一些问题来明确理解你的问题。是的,这是我关于。。。本例如您所说注册本地函数。但对了,我问了如何注册类方法。我对NuSOAP不是很流利,所以我不能直接告诉你。这可能是可能的,但可能不是(或者您需要编写一个包装器)。NuSOAP文档在这里下载:好的,很好。但是调用的外观:)$client=newsoapclient();和$client->myClass.ShowString:)因为我无法让它工作:(nusoap代理中似乎有一个bug,它阻止它使用类封装的函数。如果使用
$client->call('ImplClass.myfunc');
它工作得很好。这使得无法解决的是,您无法通过从实现类继承来迭代扩展SOAP接口。
[File 'myClass.class.inc.php']

class myClass{

     public function __construct(){

     }


     public function ShowString($mens){

        return "\n##Remote Class :".__CLASS__."\n##Remote Method : ".__METHOD__."\n## mSG :{$mens}";

     }

}
$proxy->className__methodname