opencart 的 nusoap 实施
希望这里有人熟悉OpenCart。我在 OpenCart 上实施 Nusoap 时遇到问题。这是我的实现,
- 我创建了一个名为 ws.php 的新库文件(我在 system/library/ 中有整个 nusoap 文件夹)
<前><代码>
- 我在catalog/controller/webservice/ws.php中创建了一个控制器文件
<前><代码>加载->library('ws'); $ws = new Ws(); $this->nusoap_server = newsoap_server(); $this->nusoap_server->configureWSDL("MemberWSDL","瓮:MemberWSDL"); $this->nusoap_server->注册( "选择会员信息", 大批( “id” => “xsd:int”, ), 数组(“返回”=>“xsd:字符串”), “瓮:会员WSDL”, “瓮:MemberWSDL#selectMemberInfo”, “rpc”, “编码”, 「获取会员信息」 ); }
函数索引(){ $this->nusoap_server->service(file_get_contents("php://input")); } 函数 select_member_info() { 函数 selectMemberInfo($member_id) { 返回“你好”; }
$this->nusoap_server->service(file_get_contents("php://input")); } } ?>
- 这是我的肥皂客户端,驻留在 OpenCart 的应用程序上
$nusoap_client=new nusoap_client("http://localhost/opencart/index.php?route=webservice/ws"); $id = 90001; if($nusoap_client->故障) { $text = '错误:'.$nusoap_client->故障;
<前><代码> } 别的 { if ($nusoap_client->getError()) { $text = '错误:'.$nusoap_client->getError(); } 别的 { $row = $nusoap_client->call( '选择会员信息', 数组($id), '瓮:会员WSDL', '瓮:MemberWSDL#selectMemberInfo' ); 回声'
'.htmlspecialchars($nusoap_client->response, ENT_QUOTES).''; } }?>
这就是我得到的
HTTP/1.1 500 内部服务器错误 服务器:Microsoft-IIS/5.1 日期: 2011 年 10 月 4 日星期二 04:47:41 GMT 内容类型:text/xml; charset=ISO-8859-1 X-Powered-By: PHP/5.3.1 Set-Cookie: PHPSESSID=fas5fisb84rcs3g94njljhrhk4; path=/ 到期时间: 1981 年 11 月 19 日,星期四 08:52:00 GMT 缓存控制:无存储、无缓存、必须重新验证、 post-check=0,pre-check=0 Pragma:无缓存 Set-Cookie:语言=en; 过期=2011 年 11 月 3 日星期四 04:47:41 GMT;路径=/;域=本地主机 Set-Cookie:货币=MYR;过期=2011 年 11 月 3 日星期四 04:47:41 GMT; 路径=/;域=本地主机 服务器:NuSOAP 服务器 v0.7.3 X-SOAP-服务器: NuSOAP/0.7.3 (1.114) 内容长度:692
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> SOAP-ENV:未定义客户端方法“selectMemberInfo” 服务中
OpenCart 中实现 Nusoap/SOAP 或者知道我的实现中出了什么问题?
提前致谢。
Hope that someone is familiar with OpenCart here. I have problem with my Nusoap implementation on OpenCart. This is my implementation
- I created a new library file called ws.php (I have the entire nusoap folder in system/library/)
<?php final class Ws { public function __construct() { require_once('nusoap/nusoap.php'); } } ?>
- I created a controller file in catalog/controller/webservice/ws.php
<?php class ControllerWebserviceWs extends Controller { private $error = array(); function __construct($registry) { parent::__construct($registry); $this->load->library('ws'); $ws = new Ws(); $this->nusoap_server = new soap_server(); $this->nusoap_server->configureWSDL("MemberWSDL",
"urn:MemberWSDL");
$this->nusoap_server->register(
"selectMemberInfo",
array(
"id" => "xsd:int",
),
array("return"=>"xsd:string"),
"urn:MemberWSDL",
"urn:MemberWSDL#selectMemberInfo",
"rpc",
"encoded",
"Get member's info"
);
}function index(){ $this->nusoap_server->service(file_get_contents("php://input")); } function select_member_info() { function selectMemberInfo($member_id) { return 'hello'; }
$this->nusoap_server->service(file_get_contents("php://input"));
}
}
?>
- This is my soap client residing on an application out of OpenCart
$nusoap_client=new
nusoap_client("http://localhost/opencart/index.php?route=webservice/ws");
$id = 90001; if($nusoap_client->fault)
{
$text = 'Error: '.$nusoap_client->fault;} else { if ($nusoap_client->getError()) { $text = 'Error: '.$nusoap_client->getError(); } else { $row = $nusoap_client->call( 'selectMemberInfo', array($id), 'urn:MemberWSDL', 'urn:MemberWSDL#selectMemberInfo' ); echo
'
'.htmlspecialchars($nusoap_client->response, ENT_QUOTES).'';
}
}?>
And this is what I get
HTTP/1.1 500 Internal Server Error Server: Microsoft-IIS/5.1 Date:
Tue, 04 Oct 2011 04:47:41 GMT Content-Type: text/xml;
charset=ISO-8859-1 X-Powered-By: PHP/5.3.1 Set-Cookie:
PHPSESSID=fas5fisb84rcs3g94njljhrhk4; path=/ Expires: Thu, 19 Nov 1981
08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: language=en;
expires=Thu, 03-Nov-2011 04:47:41 GMT; path=/; domain=localhost
Set-Cookie: currency=MYR; expires=Thu, 03-Nov-2011 04:47:41 GMT;
path=/; domain=localhost Server: NuSOAP Server v0.7.3 X-SOAP-Server:
NuSOAP/0.7.3 (1.114) Content-Length: 692xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
SOAP-ENV:Clientmethod 'selectMemberInfo' not defined
in service
Have anyone tried to implement Nusoap/SOAP in OpenCart or any idea what goes wrong in my implementation?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有同样的问题。但我意识到,如果您将
select_member_info()
放在主类之外,它就可以工作!一旦找到可行的解决方案,我就会再次写信。
I have the same problem. But i realized that if you put the
select_member_info()
outside the main class, it is working!I will write again as soon as i get a working solution.