Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Soap Call fails

by PerlMASA (Novice)
on Oct 24, 2020 at 03:24 UTC ( #11123107=perlquestion: print w/replies, xml ) Need Help??

PerlMASA has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to call a Soap Webservice.I have to pass the name of a Code table (for eg STATE_CODES) and it returns key value pair like NY - New york, DE-Delaware etc.

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper qw<Dumper>; #use SOAP::Lite trace=>'all'; use SOAP::Lite +trace =>'debug'; #use SOAP::Lite; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1; #my $wsdl = 'https://dev1:2001/ACTS?wsdl'; my $endpoint = 'https://qa1:2001/ACTS'; my $wsdl = 'HTTPS://QA1:2001/ACTS?wsdl'; my $method_name = 'impl:getCodes'; my $uri = 'http://impl.webservice.acts.ito.aoc.nj'; my $ns = 'http://impl.webservice.acts.ito.aoc.nj'; my $client = SOAP::Lite->new( proxy=>$endpoint, service=>$wsdl, readable=>1 ); $client->outputxml(1); $client->envprefix('soapenv'); $client->ns($uri,'impl'); $client->outputxml('true'); my @param; push @param, SOAP::Data->name("codeTable"=>'STATE_CODES'); my $soapResp = $client->call($method_name,@param); print $soapResp; print "\n";

output is as below
root@np1 ~# perl /test/soaptest6.pl
SOAP::Transport::HTTP::Client::send_receive: POST https://qa1:2001/ACTS HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 580
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://impl.webservice.acts.ito.aoc.nj#getCodes"

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:impl="http://impl.webservice.acts.ito.aoc.nj"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<impl:getCodes>
<codeTable xsi:type="xsd:string">STATE_CODES</codeTable>
</impl:getCodes>
</soapenv:Body>
</soapenv:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Error
Connection: close
Content-Type: text/xml; charset=utf-8
Client-Date: Sat, 24 Oct 2020 02:46:04 GMT
Client-Peer: 192.168.248.33:2001
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /CN=qa1
Client-SSL-Cert-Subject: /CN=qa1
Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
X-Backside-Transport: FAIL FAIL

<?xml version='1.0' ?>
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Internal Error</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
<?xml version='1.0' ?>
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Internal Error</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>

The soap request kind of looks good, but it gives error. I pasted the soap request into SOAPUI from the soapActionand it worked.

Why is my soap request resulting in failure. is it because of some certificate issue. i believe i have asked the code to skip certificate validation and Client-SSL-Warning: Peer certificate not verified in output above is just a warning and can be ignored

Is the line between getCodes" and <?xml version="1.0"... in soapAction causing failure. The request failed in SOAPUI if I added a line before the <?xml version="1.0"...

if it helps, the soap webservice is a java application on websphere and it is being accessed by perl through datapower.

Replies are listed 'Best First'.
Re: Soap Call fails
by jo37 (Friar) on Oct 24, 2020 at 07:21 UTC

    If the same request is working in SoapUI, then look at the headers sent with the request. Make sure you're using the same with your request from Perl.
    Also check if a client certificate is requested and provided by SoapUI.
    It would be very helpful to see the error on the server side, too.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
      Double checking if my server is getting request or not

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11123107]
Approved by GrandFather
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2020-11-28 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?