Perl SOAP::WSDL 访问 HTTPS 未经授权的错误
我正在尝试生成一个 Perl 库来连接到 WebService。该网络服务位于 HTTPS 服务器中,我的用户可以访问它。
我已经使用不同的选项执行了 wsdl2perl.pl 多次,但它总是失败并显示以下消息:
Unauthorized at /usr/lib/perl5/site_perl/5.8.8/SOAP/WSDL/Expat/Base.pm line 73.`
问题是,当我不提供我的用户/通行证作为参数时,它甚至不会要求它们。
我读过 SOAP ::WSDL::Manual::Cookbook 并完成了有关 HTTPS 的操作:Crypt::SSLeay 已安装,并且两者都已安装修改 SOAP::WSDL::Transport::HTTP 和 SOAP::Transport::HTTP。
您能给出任何可能出现问题的提示吗?
I'm trying to generate a Perl library to connect to a WebService. This webservice is in an HTTPS server and my user has access to it.
I've executed wsdl2perl.pl several times, with different options, and it always fails with the message:
Unauthorized at /usr/lib/perl5/site_perl/5.8.8/SOAP/WSDL/Expat/Base.pm line 73.`
The thing is, when I don't give my user/pass as arguments, it doesn't even asks for them.
I've read SOAP::WSDL::Manual::Cookbook and done what it says about HTTPS: Crypt::SSLeay is instaleld, and both SOAP::WSDL::Transport::HTTP and SOAP::Transport::HTTP are modified.
Can you give any hint about what may be going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您引用的错误消息似乎来自这一行:
如果 $response->code() ne '200',则 $response->message() 死亡;
在 HTTP 世界中,
Unauthorized
显然是错误代码 401,这意味着您的网站要求输入用户名和密码(很可能,某些网站可能会“劫持”此错误代码来满足其他条件,例如过滤器)在源 IP 上)。你有吗?
如果是这样,您可以
wdsl2perl
运行后,在创建的文件中找到调用set_proxy()
的位置,并更改其中的 URL 以包含用户名和密码,如下所示:...->set_proxy('http://用户名:[email protected]/...')
SOAP::WSDL
对象后,调用 < code>service(SERVICENAME) (对于您在其中定义的每个服务)您的 WSDL 文件),这会为您提供一个新对象,您可以在该对象上调用transport()
来访问底层传输对象,您可以在该对象上使用 URL 调用proxy()
如上面的格式(是的,这里是proxy()
,上面是set_proxy()
);或者您调用credentials()
而不是proxy()
并传递 4 个字符串:The error message you quote seems to be from this line :
die $response->message() if $response->code() ne '200';
and in HTTP world,
Unauthorized
is clearly error code 401, which means your website asks for a username and password (most probably, some website may "hijack" this error code to cater for other conditions like a filter on the source IP).Do you have them?
If so, you can
wdsl2perl
has run, find in the created files whereset_proxy()
is called and change the URL in there to include the username and password like that :...->set_proxy('http://USERNAME:[email protected]/...')
SOAP::WSDL
object, callservice(SERVICENAME)
on it (for each service you have defined in your WSDL file), which gives you a new object, on which you calltransport()
to access the underlying transport object on which you can callproxy()
with the URL as formatted above (yes it isproxy()
here andset_proxy()
above); or you callcredentials()
instead ofproxy()
and you pass 4 strings:如果没有必要,我不建议你使用perl作为web服务客户端。正如你所知,perl是一种开源语言,虽然它确实支持soap协议,但它的支持似乎不是很标准。首先,它的文档不是很清楚。而且,它的支持有时是有限的。最后,bug总是存在。
所以,如果你必须使用wsdl2perl,你可以使用komodo单步执行代码来找出发生了什么。这正是我以前使用perl作为Web服务客户端时所做的事情。你知道,在https后面是SSL,所以,如果你的SSL是基于证书授权的,你必须设置你的证书路径和可信服务器证书列表。你最好使用基于linux的firefox进行测试。据我所知,您可以设置firefox的证书路径和firefox的受信任证书列表。如果firefox可以成功地与您的Web服务服务器通信,那么就可以调试您的perl客户端了。
If not necessary ,I don't recommend you to use perl as a web service client .As you know ,perl is a open-source language,although it do support soap protocol,but its support do not seem very standard.At first,its document is not very clear.And also ,its support sometimes is limited.At last,bug always exists here and there.
So ,if you have to use wsdl2perl,you can use komodo to step into the code to find out what happened.This is just what I used to do when using perl as a web service client.You know ,in the back of https is SSL,so ,if your SSL is based on certificate-authorized,you have to set up your cert path and the list of trusted server cert.You'd better use linux-based firefox to have a test.As I know ,you can set up firefox's cert path and firefox's trusted cert list.If firefox can communicated with your web service server succefully,then,it's time to debug your perl client.