Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Soap::Lite and Complex Types with WSDL

by firstaspect (Initiate)
on May 11, 2011 at 13:06 UTC ( #904155=perlquestion: print w/ replies, xml ) Need Help??
firstaspect has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to connect to a web service using SOAP::Lite using a WSDL file. Now everything works as expected apart from the Complex Type that I need to pass in which just seems to get ignored in the REQUEST header so isn't sent. This is the valid XML for the complex type (checked in SoapUI):
<ListOfAccountContactInterface> <Account> <CompanyId>1029843</ConnectCompanyId> <ListOfContact> <Contact> <ContactId>CON12347</ContactId> </Contact> </ListOfContact> </Account> </ListOfAccountContactInterface>
I'm using the following code to try to generate that same thing for SOAP::Lite:
my $param = SOAP::Data->name("ListOfAccountContactInterface" => \SOAP: +:Data->value( SOAP::Data->name("Account" => \SOAP::Data->value( SOAP::Data->name("CompanyId" => '1029843'), SOAP::Data->name("ListOfContact" => \SOAP::Data->value( SOAP::Data->name("Contact" => \SOAP::Data->value( SOAP::Data->name("<ContactId>" => 'CON12347') )) )) )) ));
But then when I pass that through SOAP::Lite using the below it just gets left out of the request header:
my $soap_result = SOAP::Lite -> service('file:/home/wsdl/Contact_Interface.wsdl') -> ContactInsertOrUpdate($param);
Hope that makes sense, and any help would be greatfully received.

Comment on Soap::Lite and Complex Types with WSDL
Select or Download Code
Replies are listed 'Best First'.
Re: Soap::Lite and Complex Types with WSDL
by Anonymous Monk on May 11, 2011 at 14:19 UTC
    Element '<ConnectContactId>' can't be allowed in valid XML message. Died. at C:/perl/site/5.12.2/lib/SOAP/ line 1412.
    a tidy request
    $ perl POST http://localhost/blah/DummyService HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/0.712 Content-Length: 700 Content-Type: text/xml; charset=utf-8 SOAPAction: "#ContactInsertOrUpdate" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle=" +oding/" xmlns:soap="" xmlns: +soapenc="" xmlns:xsd="http:/ +/" xmlns:xsi=" +ma-instance"> <soap:Body> <ContactInsertOrUpdate> <ListOfArmAccountContactInterface> <ARMAccount> <ContactCompanyId xsi:type="xsd:int">1029843</ContactCompany +Id> <ListOfArmContact> <ARMContact> <ConnectContactId xsi:type="xsd:string">CON12347</Connec +tContactId> </ARMContact> </ListOfArmContact> </ARMAccount> </ListOfArmAccountContactInterface> </ContactInsertOrUpdate> </soap:Body> </soap:Envelope>
    #!/usr/bin/perl -- use SOAP::Lite; my $soap = SOAP::Lite ->proxy( 'http://localhost/blah/DummyService', timeout => 0.00001, ); $soap->transport->add_handler("request_send", \&pp_dump ); $soap->transport->add_handler("response_done", \&pp_dump ); my $param = SOAP::Data->name( "ListOfArmAccountContactInterface" => \SOAP::Data->value( SOAP::Data->name( "ARMAccount" => \SOAP::Data->value( SOAP::Data->name( "ContactCompanyId" => '1029843' ), SOAP::Data->name( "ListOfArmContact" => \SOAP::Data->value( SOAP::Data->name( "ARMContact" => \SOAP::Data->value( #~ SOAP::Data->name("<ConnectContactId>" => 'CON12347' +) SOAP::Data->name( "ConnectContactId" => 'CON12347' ) ) ) ) ) ) ) ) ); #~ print pp( #~ $soap->serializer()->envelope( #~ method => 'ContactInsertOrUpdate', #~ $param #~ ), #~ ), "\n\n"; $soap->call( 'ContactInsertOrUpdate', $param ); sub pp { use XML::Twig; open my($fh), '>', \my $str; no warnings 'newline'; XML::Twig->new(qw! pretty_print record !)->xparse(@_)->print( $fh +); return $str; } sub pp_dump { my $content = $_[0]->content(''); $_[0]->content( pp($content) ); print $_[0]->as_string,"\n"; return; } __END__
      As far as I'm aware I can't use SOAP::Lite->proxy while using a local file location for my WSDL file? It doesn't like the 'file:/' like SOAP::Lite->service does. Thanks.
        As far as I'm aware I can't use SOAP::Lite->proxy while using a local file location for my WSDL file? It doesn't like the 'file:/' like SOAP::Lite->service does. Thanks.

        I don't know what you mean by that. See How do I post a question effectively?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2016-02-12 18:50 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (412 votes), past polls