Perl SOAP :: WSDL, access to HTTPS Unathorized error

I am trying to create a Perl library to connect to a WebService. This web service is located on an HTTPS server and my user has access to it.

I executed wsdl2perl.pl several times, with different parameters, 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 that when I do not pass my user / password as arguments, it doesn’t even ask for them.

I read [SOAP :: WSDL :: Manual :: Cookbook] (http://search.cpan.org/~mkutter/SOAP-WSDL-2.00.10/lib/SOAP/WSDL/Manual/Cookbook.pod) and did what he says about HTTPS: Crypt :: SSLeay is instaleld, and both SOAP :: WSDL :: Transport :: HTTP and SOAP :: Transport :: HTTP are changed.

Can you give any hint on what might go wrong?

+6
source share
4 answers

Can you freely access the WSDL file from your web browser? Can someone else on your network access it without any problems?

Perhaps the web server hosting the WSDL file requires Basic or some other type of authentication ...

0
source

If this is not necessary, I do not recommend using perl as a web service client. As you know, perl is an open source language, although it supports the soap protocol, but its support does not seem very standard. Firstly, his document is not very clear. In addition, his support is sometimes limited. Finally, a mistake always exists here and there.

So, if you need to use wsdl2perl, you can use komodo to enter the code to find out what happened. This is what I did when using perl as a web service client. You know, in the back of https, this is SSL, so if your SSL is based on authorization, you need to configure your certification path and the list of trusted server certificates. Better use linux-based firefox for testing. As I know, you can configure the path to the firefox certificate and the list of trusted firefox certificates. If firefox can be successfully transferred with your web services server, then it will take time to debug your perl client.

0
source

To debug situations with Perl and SOAP, insert a web proxy so you can see exactly what data is being sent and what response is being returned from the server. I expect you to receive 401 Not authorized, but there may be more details in the server response.

Both Fiddler http://docs.telerik.com/fiddler and Charles proxy https://www.charlesproxy.com/ can do this.

0
source

The error message you specify seems to apply to this line: die $response->message() if $response->code() ne '200'; and in the HTTP Unauthorized world, explicitly the error code is 401, which means that your site is asking for a username and password (most likely, some site may “capture” this error code in order to serve other conditions, such as a filter on the source IP address ), Do you have them?

If so, you can

  • after wdsl2perl starts up, look in the created files where set_proxy() is called, and change the URL there to include the username and password: ...->set_proxy('http://USERNAME: PASSWORD@www.example.com /...')
  • or your code, after creating the SOAP::WSDL object, call service(SERVICENAME) on it (for each service defined in the WSDL file), which gives you a new object that you call transport() on to access the base transport object , which you can call proxy() with the URL formatted above (yes, this is proxy() here and set_proxy() above); or you call credentials() instead of proxy() , and you pass 4 lines:
    • 'HOSTNAME: PORT
    • the area specified by the web server, but I think you can put anything
    • Username
    • password
0
source

Source: https://habr.com/ru/post/899775/


All Articles