Perl SOAP::WSDL 访问 HTTPS 未经授权的错误

发布于 2024-12-11 07:26:24 字数 558 浏览 0 评论 0原文

我正在尝试生成一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

和影子一齐双人舞 2024-12-18 07:26:24

您引用的错误消息似乎来自这一行:
如果 $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 个字符串:
    1. “主机名:端口”
    2. 领域,由网络服务器给出,但我认为你可以放置任何内容
    3. 用户名
    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

  • after wdsl2perl has run, find in the created files where set_proxy() is called and change the URL in there to include the username and password like that : ...->set_proxy('http://USERNAME:[email protected]/...')
  • or your in code, after instantiating the SOAP::WSDL object, call service(SERVICENAME) on it (for each service you have defined in your WSDL file), which gives you a new object, on which you call transport() to access the underlying transport object on which you can call proxy() with the URL as formatted above (yes it is proxy() here and set_proxy() above); or you call credentials() instead of proxy() and you pass 4 strings:
    1. 'HOSTNAME:PORT'
    2. the realm, as given by the webserver but I think you can put anything
    3. the username
    4. the password
朱染 2024-12-18 07:26:24

如果没有必要,我不建议你使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文