Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

SOAP::LITE client help

by Wroof (Novice)
on Apr 30, 2014 at 23:44 UTC ( #1084556=perlquestion: print w/replies, xml ) Need Help??

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

Good morning Monks

I have been trying to write a client to access a soap server for a job and am very new to Perl and SOAP. I have been given the following information from the server and need to write a client for it. If someone use their vast knowledge to help me access the first function then I am sure I can take the rest :)

SOAP 1.1 HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap=""> <soap:Body> <getCardInfoResponse xmlns=""> <getCardInfoResult> <AmountPayed>int</AmountPayed> <AmountDue>int</AmountDue> <AmountDueCurrency>decimal</AmountDueCurrency> <AmountDuePeriodStart>dateTime</AmountDuePeriodStart> <AmountDuePeriodEnd>dateTime</AmountDuePeriodEnd> <CardUID>guid</CardUID> <ISONumber>string</ISONumber> <CardType>int</CardType> <CarparkUID>guid</CarparkUID> <CarparkNr>int</CarparkNr> <CodingTime>dateTime</CodingTime> <LastTccNumber>int</LastTccNumber> <LastTccTime>dateTime</LastTccTime> <NumberOfPayments>int</NumberOfPayments> <GracePeriod>int</GracePeriod> <VAT>int</VAT> <MoneyConversionFactor>decimal</MoneyConversionFactor> <Currency>string</Currency> <Cheater>boolean</Cheater> <RabattInfo> <Wert>int</Wert> <Zeit>int</Zeit> <Promille>int</Promille> <PromilleGeb>int</PromilleGeb> <GID>int</GID> <NullUntil>int</NullUntil> <CaOrder>string</CaOrder> <WertVerr>int</WertVerr> <ZeitVerr>int</ZeitVerr> <RabattBetragAbsolut>int</RabattBetragAbsolut> </RabattInfo> </getCardInfoResult> </getCardInfoResponse> </soap:Body> </soap:Envelope> SOAP 1.2 HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="" + xmlns:xsd="" xmlns:soap12=""> <soap12:Body> <getCardInfoResponse xmlns=""> <getCardInfoResult> <AmountPayed>int</AmountPayed> <AmountDue>int</AmountDue> <AmountDueCurrency>decimal</AmountDueCurrency> <AmountDuePeriodStart>dateTime</AmountDuePeriodStart> <AmountDuePeriodEnd>dateTime</AmountDuePeriodEnd> <CardUID>guid</CardUID> <ISONumber>string</ISONumber> <CardType>int</CardType> <CarparkUID>guid</CarparkUID> <CarparkNr>int</CarparkNr> <CodingTime>dateTime</CodingTime> <LastTccNumber>int</LastTccNumber> <LastTccTime>dateTime</LastTccTime> <NumberOfPayments>int</NumberOfPayments> <GracePeriod>int</GracePeriod> <VAT>int</VAT> <MoneyConversionFactor>decimal</MoneyConversionFactor> <Currency>string</Currency> <Cheater>boolean</Cheater> <RabattInfo> <Wert>int</Wert> <Zeit>int</Zeit> <Promille>int</Promille> <PromilleGeb>int</PromilleGeb> <GID>int</GID> <NullUntil>int</NullUntil> <CaOrder>string</CaOrder> <WertVerr>int</WertVerr> <ZeitVerr>int</ZeitVerr> <RabattBetragAbsolut>int</RabattBetragAbsolut> </RabattInfo> </getCardInfoResult> </getCardInfoResponse> </soap12:Body> </soap12:Envelope> HTTP POST HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <CardInfo xmlns=""> <AmountPayed>int</AmountPayed> <AmountDue>int</AmountDue> <AmountDueCurrency>decimal</AmountDueCurrency> <AmountDuePeriodStart>dateTime</AmountDuePeriodStart> <AmountDuePeriodEnd>dateTime</AmountDuePeriodEnd> <CardUID>guid</CardUID> <ISONumber>string</ISONumber> <CardType>int</CardType> <CarparkUID>guid</CarparkUID> <CarparkNr>int</CarparkNr> <CodingTime>dateTime</CodingTime> <LastTccNumber>int</LastTccNumber> <LastTccTime>dateTime</LastTccTime> <NumberOfPayments>int</NumberOfPayments> <GracePeriod>int</GracePeriod> <VAT>int</VAT> <MoneyConversionFactor>decimal</MoneyConversionFactor> <Currency>string</Currency> <Cheater>boolean</Cheater> <RabattInfo> <Wert>int</Wert> <Zeit>int</Zeit> <Promille>int</Promille> <PromilleGeb>int</PromilleGeb> <GID>int</GID> <NullUntil>int</NullUntil> <CaOrder>string</CaOrder> <WertVerr>int</WertVerr> <ZeitVerr>int</ZeitVerr> <RabattBetragAbsolut>int</RabattBetragAbsolut> </RabattInfo> </CardInfo>

So far I have not even been able to create the most basic connection using Perl and am a complete loss as to what to do next. Below is my code to call the method isAlive that the server also has.

my ($isbn_number) = @ARGV; use SOAP::Lite +autodispatch=> uri=>'', outputxml=>1, proxy=>' +smx'; my $isbn_xml = isAlive(); print "$isbn_xml\n";

As you can probably tell I have modified this from an example. Below is the output I get

Use of inherited AUTOLOAD for non-method main::isAlive() is deprecate +d at C:\Use rs\Sam\Documents\Perl code\ line 15. <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http: +//schemas." xmlns:xsi=" +a-instance " xmlns:xsd=""><soap:Body><soap:Fault> +<faultcode >soap:Client</faultcode><faultstring>Server did not recognize the valu +e of HTTP Header SOAPAction:</faultstring><detai +l /></soap :Fault></soap:Body></soap:Envelope> Press any key to continue . . .

Replies are listed 'Best First'.
Re: SOAP::LITE client help
by Khen1950fx (Canon) on May 01, 2014 at 04:24 UTC
    In general, I would try something along these lines; also, you'll need warnings::everywhere.
    #!/usr/bin/perl -l use strict; no warnings::anywhere qw(deprecated); use warnings qw(deprecated); my $isbn = shift @ARGV; use SOAP::Lite +autodispatch => uri => '', proxy => ' +smx', on_fault => sub { my ( $soap, $res ) = @_; die ref $res ? $res->faultdetail : $soap->transport->status; }; isAlive( $isbn ); print SOAP::Lite->self->call->result;
    Update: fixed typo - should be a comma at end of line 11.

      Thanks for your help. When I try and run this code after installing warnings::Everywhere I get the following errors.

      Use of uninitialized value $_[0] in pattern match (m//) at C:/Strawber +ry/perl/si te/lib/SOAP/ line 340. Use of uninitialized value in sprintf at C:/Strawberry/perl/site/lib/S +OAP/Lite.p m line 3612. Press any key to continue . . .

      I have also tried another piece of code to see what happens and this one returns no errors but it also does not output anything other that the test points I put in. This uses the WSDL on the page.

      #!/usr/bin/perl -w use strict; use diagnostics; use warnings; use Data::Dumper; eval { require SOAP::Lite; }; die "Fehler:\n$@\n\n" if $@; my $soap = SOAP::Lite->new(); print "test \n"; my $service = $soap->service(' +rviceCashPoint.asmx?wsdl'); print Dumper($service->getCardInfo('ws','ws','45','pm01001011000000003 +7')); print "test \n";
        Thanks for the response. I fixed a typo. Please try it again.
Re: SOAP::LITE client help
by Anonymous Monk on May 01, 2014 at 02:35 UTC
Re: SOAP::LITE client help
by Wroof (Novice) on May 02, 2014 at 01:28 UTC

    Ok so thank you everyone for you help so far. Currently I have not have not been able to get much back from the system so I have decided to try the html approach in Perl. Below is the code

    #!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Request::Common; my $userAgent = LWP::UserAgent->new(agent => 'perl post'); my $message = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap12:Envelope xmlns:xsi=\" +\" xmlns:xsd=\"\" xmlns:soap12=\"\"> <soap12:Body> <getCardInfo xmlns=\"\"> <UserID>ws</UserID> <UserPWD>ws</UserPWD> <TccNum>45</TccNum> <CardNumber>\"PM010010110000000037\"</CardNumber> </getCardInfo> </soap12:Body> </soap12:Envelope>" ; my $response = $userAgent->request(POST ' +bService/ServiceCashPoint.asmx/getCardInfo', Content_Type => 'text/plain', Content => $message); print $response->error_as_HTML unless $response->is_success; print $response->as_string;

    Now I can connect for the isAlive command and get a response bac even though it is in a xml format. How ever when I try and and request getCardInfo which is to return a few different things I get a error saying Request format is invalid. I know I am missing something simple but for the life of me I cannot work it out. Once again thanks for all the help

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1084556]
Approved by rnewsham
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2020-08-12 14:55 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (66 votes). Check out past polls.