Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

SOAP::Lite syntax

by graq (Curate)
on Oct 11, 2005 at 08:40 UTC ( [id://499060]=perlquestion: print w/replies, xml ) Need Help??

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

I have a client running .NET web services soap server and I am trying to write a SOAP::Lite client, but I can't seem to get the syntax right.

WSDL Snippet:

<?xml version="1.0" encoding="utf-8"?> <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns: +soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="h ttp://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.the-client.info/ +Service" xmlns:soapenc="http://schemas.xmlsoap.org/soap /encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xm +lns:mime="http://schemas.xmlsoap.org/wsdl/mime/" target Namespace="http://www.theClient.info/Service" xmlns="http://schemas.xm +lsoap.org/wsdl/"> <types> <s:schema elementFormDefault="qualified" targetNamespace="http://w +ww.theClient.info/Service"> <s:import namespace="http://www.w3.org/2001/XMLSchema" /> <s:element name="companyData"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="eventCode" ty +pe="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="userName" typ +e="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="password" typ +e="s:string" /> </s:sequence> </s:complexType> </s:element> <s:element name="companyDataResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="companyDataRe +sult"> <s:complexType> <s:sequence> <s:element ref="s:schema" /> <s:any /> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element> </s:schema> </types> <message name="companyDataSoapIn"> <part name="parameters" element="s0:companyData" /> </message> <message name="companyDataSoapOut"> <part name="parameters" element="s0:companyDataResponse" /> </message> <portType name="clientServiceSoap"> <operation name="companyData"> <input message="s0:companyDataSoapIn" /> <output message="s0:companyDataSoapOut" /> </operation> </portType> <binding name="clientServiceSoap" type="s0:clientServiceSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" sty +le="document" /> <operation name="companyData"> <soap:operation soapAction="http://www.the-client.info/Service/c +ompanyData" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <service name="clientService"> <port name="clientServiceSoap" binding="s0:clientServiceSoap"> <soap:address location="http://www.theclient.com/clientService.a +smx" /> </port> </service> </definitions>

Every request should be sent an eventCode, userName and password which is then used to authenticate with (this is not web server or cookie auth, just in their code).

I'm stuck on the syntax.

#!perl use SOAP::Lite;# +trace; use Data::Dumper; use strict; my @foo = ('Event01', 'USER', 'pass'); my $soap= SOAP::Lite -> service('http://www.theClient.com/service.asmx?WSDL') -> companyData( \@foo ); # print $soap->response; print Dumper($soap);

UPDATE: I have found some information on the wsdl from the Microsoft Support site. Maybe I need to rewrite the wsdl and use it locally?

Their "IT person" is a contractor (not in the office), but have found some docs that state the soap server expectations:
POST /service.asmx HTTP/1.1 Host: www.theClient.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.theClient.info/Service/companyData" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schema +s.xmlsoap.org/soap/envelope/"> <soap:Body> <companyData xmlns="http://www.theClient.info/Service"> <eventCode>string</eventCode> <userName>string</userName> <password>string</password> </companyData> </soap:Body> </soap:Envelope>

It should be a simple problem? It is just my unfamiliarity with SOAP that is causing me problems.

Replies are listed 'Best First'.
Re: SOAP::Lite syntax
by graq (Curate) on Oct 11, 2005 at 12:34 UTC
    So anyway, now that I know that the .NET server is configured as literal, this seems to solve my problem:
    #!perl use Data::Dumper; use SOAP::Lite; my $soap = SOAP::Lite -> uri('http://www.theClient.info/Service') -> on_action( sub { join '/', 'http://www.theClien.info/Service', +$_[1] } ) -> proxy('http://www.theClien.com/Service.asmx') -> autotype(0); my $method = SOAP::Data->name('companyData')->attr( {xmlns=>"http://ww +w.theClien.info/Service"} ); my $eventCode = SOAP::Data->name('eventCode' => 'EVENT01'); my $userName = SOAP::Data->name('userName' => 'USER'); my $password = SOAP::Data->name('password' => 'PASS'); my $som = $soap->call($method => ( SOAP::Data->name('eventCode' => $eventCode), SOAP::Data->name('userName' => $userName), SOAP::Data->name('password' => $password) ));

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://499060]
Approved by muntfish
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found