mrguy123 has asked for the wisdom of the Perl Monks concerning the following question:
As I have said, this was the way most of the programs sent their info. However, this particular program used the SOAP::Lite module to create the same search request. The code is:#!/usr/bin/perl use HTTP::Cookies; use strict; use LWP::UserAgent; { my $ua = new LWP::UserAgent; $ua->cookie_jar(HTTP::Cookies->new()); push @{$ua->requests_redirectable}, 'POST'; my $search_command = "http://wok-ws.isiknowledge.com/esti/soap/Sea +rchRetrieve"; my $content = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Env +elope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOA +P-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="htt +p://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/ +1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/so +ap/encoding/"><SOAP-ENV:Body><namesp1:search xmlns:namesp1="http://wo +k-ws.isiknowledge.com/esti/soap/SearchRetrieve?wsdl"><databaseId xsi: +type="xsd:string">DIIDW</databaseId><query xsi:type="xsd:string">TS=( +create)</query><editions xsi:type="xsd:string"/><firstRec xsi:type="x +sd:int">1</firstRec><numRecs xsi:type="xsd:int">1</numRecs></namesp1: +search></SOAP-ENV:Body></SOAP-ENV:Envelope>'; my $header = new HTTP::Headers ( 'Content-Type' => 'text/xml; charset=utf-8', 'User-Agent' => 'PHP SOAP 0.1', 'Content-Type' => 'text/xml; charset=utf-8', 'SOAPAction' => "http://wok-ws.isiknowledge.com/esti/soap +/SearchRetrieve?wsdl#search", ); my $req = new HTTP::Request('POST',$search_command,$header,$conten +t); my $res = $ua->request($req); print $req->as_string."\n"; my $response = $res->headers_as_string(); my $response .= $res->content; print "---response---\n$response\n"; }
As you can see, the code is much more simple, and basically creates the same request from scratch. If you run both demos, you should get the same output. In fact, I built the first demo from the second, using the info that was sent through the module to "convert" the transaction. However, when I tried to convert the other programs from the LWP::UserAgent form of transaction to the SOAP::Lite form, I failed miserabely.#!/exlibris/metalib/m4_b/product/bin/perl sub BEGIN { unshift (@INC, $ENV{'aleph_ext'}); unshift (@INC, "$ENV{'aleph_product'}"."/perl/lib/site_perl/5.005" +); unshift (@INC, "$ENV{'aleph_product'}"."/perl/lib/site_perl/5.005/ +i686-linux"); } use SOAP::Lite+trace => 'debug'; my $soap_request = SOAP::Lite->new(); $soap_request->uri("http://wok-ws.isiknowledge.com/esti/soap/SearchRet +rieve?wsdl"); $soap_request->proxy("http://wok-ws.isiknowledge.com/esti/soap/SearchR +etrieve"); $service = 'search'; my $soap_response = $soap_request->$service( SOAP::Data->name(databaseId => 'DIIDW'), SOAP::Data->name(query => 'TS=(create)'), SOAP::Data->name(editions => ""), SOAP::Data->name(firstRec => '1'), SOAP::Data->name(numRecs => '1'), );
2006-07-19 Retitled by holli, as per Monastery guidelines
Original title: 'SOAP::Lite vs LWP::UserAgent for SOAP transcations'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SOAP::Lite vs LWP::UserAgent for SOAP transactions
by jhourcle (Prior) on Jul 19, 2006 at 12:44 UTC | |
by mrguy123 (Hermit) on Jul 19, 2006 at 15:55 UTC | |
by gellyfish (Monsignor) on Jul 19, 2006 at 16:03 UTC | |
|
Re: SOAP::Lite vs LWP::UserAgent for SOAP transactions
by rob_au (Abbot) on Jul 19, 2006 at 12:25 UTC |