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

Dear Friends,

I hate to even impose here with my question, but it seems that I get more lost with every attempt. I realize there is more I have to educate myself on concering SOAP and the SOAP::Lite PM. So forgive me for ignorance. I've just not been able to solve this one yet.

Most of my Perl experience is with CGI and database based. So if you can help ... PLEASE!

The task I have at hand is to integrate the ability to use SOAP to attain shipping rates from a shipping provider given specific parameters (weight, zipcode from, zipcode to, etc.). They offer a WSDL interface using SOAP I presume and even give an on-line example. I just haven't been able to get it to work.

The XML, partially edited, is below that will complete the request:

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <env:Body> <m:doRateQuote xmlns:m="http://www.XXXXX.com/WebServices/HostServ +ice" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <wSRateQuoteHostRequest xmlns:ns100="java:com.XXXXX.webservice" xsi:type="ns100:WSRateQuoteHostRequest"> <destZipCode xsi:type="xsd:string">03872</destZipCode> <originZipCode xsi:type="xsd:string">30263</originZipCode> <fmsLocationId xsi:type="xsd:string">XXXXX</fmsLocationId> <weight soapenc:arrayType="xsd:string[1]"> <xsd:string xsi:type="xsd:string">100</xsd:string> </weight> <direction xsi:type="xsd:string">S</direction> <userName xsi:type="xsd:string">XXXXX</userName> <serviceCompany xsi:type="xsd:string">XXXXX</serviceCompany> <shipmentClass soapenc:arrayType="xsd:string[1]"> <xsd:string xsi:type="xsd:string">50</xsd:string> </shipmentClass> <password xsi:type="xsd:string">XXXXX</password> <chargeType xsi:type="xsd:string">P</chargeType> </wSRateQuoteHostRequest> </m:doRateQuote> </env:Body> </env:Envelope>

I've tried to implement this with the following Perl code:

#!/usr/bin/perl -w use strict; use SOAP::Lite; my $soap = SOAP::Lite ->uri('java:com.usfc.usfnet.webservice') ->proxy('http://www.usfnet.com/WebServices/HostService') ; print $soap->doRateQuote(XML FROM ABOVE)->result();

When executed, I don't get anything. No error messages. Nothing.

I am additedly only familiar with XML and even less so with SOAP. So my code could be completely irrelevant and filled with issues.

Would some kind person be willing to throw me a bone?

Thank you in advance for your kindness!

Bill

Edit by castaway - added code tags

Replies are listed 'Best First'.
Re: SOAP Beginner ... I hate to impose
by gellyfish (Monsignor) on Feb 18, 2005 at 16:36 UTC

    You can't pass the XML to the call like that you will need to build up your document using SOAP::Data and then use call you might have something rather like:

    use strict; use SOAP::Lite +trace => 'all'; + my $ns = 'http://www.XXXXX.com/WebServices/HostService'; my $ep = 'http://localhost/'; + my $lite = SOAP::Lite->uri($ns)->proxy($ep)->on_action( sub { join "", + @_ } ); + $lite->autotype(0); $lite->soapversion('1.1'); + $lite->serializer()->namespaces({'http://schemas.xmlsoap.org/soap/enve +lope/' => 'soap'}); + + $lite->autotype(0); + + my $doc = SOAP::Data->name('doRateQuote')->uri($ns)->prefix('m'); + + my $value = SOAP::Data->value( SOAP::Data->name( WSRateQuoteHostRequest => \SOAP::Data->value(SOAP::Data->name( destZipCode => '038 +72' ), SOAP::Data->name( originZipCode => '30263' ), SOAP::Data->name( fmsLocationId => 'XXXXX' ) ))->type('ns100:WSRateQuoteHostRequest') ->attr({'xmlns:ns100' => "java:com.XXXXX.webservice"})); + + + + my $res = $lite->call($doc => $value); + print $res, "\n";
    I have omitted most of the elements within WSRateQuoteHostRequest for clarity, but I guess you can work out where they have to go.

    /J\

      Thank you so much for taking the time to look at this. I will look to try to apply your knowledge (I'm still digesting some of it) within the next 2 hours and I will report what I find back here.

      Hopefully I'll have some great news to share!

      From what I see, you've already filled in some of the many holes I have on this. Thanks again!

      Bill
        I'm still attempting to work through what you gave me, but I do have a question ... The variable $ep, for proxy ... what exactly is the job of the proxy link? I've tried to look it up, read about it, and apply to what I've been given. But so far it's just not coming across. Either that or I'm just being thick.

        With it being "localhost" as you suggested, it makes it my Apache server. Does that sound correct to you?

        Thanks again ... still plugging through!

        Bill