Can't use string ("[email protected]") as a HASH ref
时间:2011-04-07
来源:互联网
client(tcl实现)使用xmlrpc和server(perl实现)通信时收到如下错误,请哪位帮忙看一下什么意思?我只负责client的实现,不懂perl。谢过了
Can't use string ("[email protected]") as a HASH ref while "strict refs" in use
at Bugzilla/WebService/User.pm line 45.
client代码:
复制代码
User.pm代码:
复制代码
Can't use string ("[email protected]") as a HASH ref while "strict refs" in use
at Bugzilla/WebService/User.pm line 45.
client代码:
- package require XMLRPC
-
- XMLRPC::create "User.login" -proxy http://bugzilla/bugzilla/tr_xmlrpc.cgi \
- -params {login string password string remember boolean}
-
- set result [User.login [email protected] 123456 0]
- puts $result
- # -*- Mode: perl; indent-tabs-mode: nil -*-
- #
- # The contents of this file are subject to the Mozilla Public
- # License Version 1.1 (the "License"); you may not use this file
- # except in compliance with the License. You may obtain a copy of
- # the License at http://www.mozilla.org/MPL/
- #
- # Software distributed under the License is distributed on an "AS
- # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- # implied. See the License for the specific language governing
- # rights and limitations under the License.
- #
- # The Original Code is the Bugzilla Bug Tracking System.
- #
- # Contributor(s): Marc Schumann <[email protected]>
- # Max Kanat-Alexander <[email protected]>
- # Mads Bondo Dydensborg <[email protected]>
- # Noura Elhawary <[email protected]>
-
- package Bugzilla::WebService::User;
-
- use strict;
- use base qw(Bugzilla::WebService);
-
- use Bugzilla;
- use Bugzilla::Constants;
- use Bugzilla::Error;
- use Bugzilla::User;
- use Bugzilla::Util qw(trim);
- use Bugzilla::Token;
- use Bugzilla::WebService::Util qw(filter validate);
-
- # Don't need auth to login
- use constant LOGIN_EXEMPT => {
- login => 1,
- offer_account_by_email => 1,
- };
-
- ##############
- # User Login #
- ##############
-
- sub login {
- my ($self, $params) = @_;
- my $remember = $params->{remember};
-
- # Username and password params are required
- foreach my $param ("login", "password") {
- defined $params->{$param}
- || ThrowCodeError('param_required', { param => $param });
- }
-
- # Convert $remember from a boolean 0/1 value to a CGI-compatible one.
- if (defined($remember)) {
- $remember = $remember? 'on': '';
- }
- else {
- # Use Bugzilla's default if $remember is not supplied.
- $remember =
- Bugzilla->params->{'rememberlogin'} eq 'defaulton'? 'on': '';
- }
-
- # Make sure the CGI user info class works if necessary.
- my $cgi = Bugzilla->cgi;
- $cgi->param('Bugzilla_login', $params->{login});
- $cgi->param('Bugzilla_password', $params->{password});
- $cgi->param('Bugzilla_remember', $remember);
-
- Bugzilla->login;
- return { id => $self->type('int', Bugzilla->user->id) };
- }
-
- sub logout {
- my $self = shift;
- Bugzilla->logout;
- return undef;
- }
作者: rossini23 发布时间: 2011-04-07
你调用的时候出错了吧?上面的看不懂不过可以猜下
-param {login string password string remember boolean}
传入参数的时候是不是应该是 'login' User.login ‘password' [email protected] ’remember‘ 123456 ‘boolean’ 0 组成的一个 hashref
下面 login 函数需要一个 hashref 参数,出错原因是你传入的不是 hashref
-param {login string password string remember boolean}
传入参数的时候是不是应该是 'login' User.login ‘password' [email protected] ’remember‘ 123456 ‘boolean’ 0 组成的一个 hashref
下面 login 函数需要一个 hashref 参数,出错原因是你传入的不是 hashref
作者: zhlong8 发布时间: 2011-04-07
本帖最后由 rossini23 于 2011-04-07 11:11 编辑
谢谢。试了一下,还是出错。这次应该是本地给出的错误。之前的错误我用wireshark抓包看到的,是server端返回的。
D:\>tclsh testopia.tcl
wrong # args: should be "User.login login password remember"
我也怀疑是传参可能跟server端不大一样,但是tcl的传参确实是这样的,怎么传都还是string。
User.login是testopia提供的API,具体描述见下面的链接:
http://landfill.bugzilla.org/tes ... ebService/User.html
QUOTE:
你调用的时候出错了吧?上面的看不懂不过可以猜下
-param {login string password string remember bool ...
zhlong8 发表于 2011-04-07 10:59
-param {login string password string remember bool ...
zhlong8 发表于 2011-04-07 10:59
谢谢。试了一下,还是出错。这次应该是本地给出的错误。之前的错误我用wireshark抓包看到的,是server端返回的。
D:\>tclsh testopia.tcl
wrong # args: should be "User.login login password remember"
我也怀疑是传参可能跟server端不大一样,但是tcl的传参确实是这样的,怎么传都还是string。
User.login是testopia提供的API,具体描述见下面的链接:
http://landfill.bugzilla.org/tes ... ebService/User.html
作者: rossini23 发布时间: 2011-04-07
那我就不懂鸟,反正提示错误的意思是传入 login 的参数应该是 hashref 却传入了 [email protected]。
作者: zhlong8 发布时间: 2011-04-07
回复 zhlong8
我又尝试了一下,发现确实是传参的问题。下面的代码就ok了,谢谢了。
复制代码
我又尝试了一下,发现确实是传参的问题。下面的代码就ok了,谢谢了。
- package require XMLRPC
-
- ::rpcvar::typedef {
- login string
- password string
- remember boolean
- } login
-
- XMLRPC::create "User.login" -proxy http://bugzilla/bugzilla/tr_xmlrpc.cgi \
- -params [list login login]
-
- set result [User.login [list login [email protected] password 123456 remember 1]]
- puts $result
作者: rossini23 发布时间: 2011-04-07
那个文档没说调用方式啊,是不是 User.login -login [email protected] -password xxx -rember 1
作者: zhlong8 发布时间: 2011-04-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28