Advertisement

06.25.2008 at 12:17AM PDT, ID: 23513557 | Points: 500
[x]
Attachment Details

How to build a correct SOAP::Lite Request

Asked by mowcia in Perl Programming Language, Extensible Markup Language (XML), SOAP

Tags: Perl, SOAP, SOAP::Lite

Hi,
i have to connect from a perl script to a soap server with a predefined format.

My Request Format has to look like this:

Start authentication
       Data version
       Data customernr
       Data reference
End authentication
Data name
Data street
Data city

This means the auth has some subelements and the main data is on the same level like the auth.

I'm not a perl guru and tried something like this:

(Code Snippet)

#!/usr/bin/perl -w

use SOAP::Lite 'trace', 'debug';

  my $soap =  SOAP::Lite
    -> proxy('http://servername.company.com/soap')
    -> uri('http://servername.company.com/soap/SoapService.wsdl');



#$soap->call(SOAP::Data->name('addGoodguy')->attr({xmlns => 'http://servername.company.com/soap/'} )
my $data = $soap->call(SOAP::Data->new(name => 'addGoodguy', type => 'xsd1:requestGGType', attr => {})
=> SOAP::Data->name('name')->value('Company Name')->type('xsd:string')
=> SOAP::Data->name('street')->value('Company Street')->type('xsd:string')
=> SOAP::Data->name('city')->value('Company City')->type('xsd:string')
=> SOAP::Data->name('country')->value('Country')->type('xsd:string')
=> SOAP::Data->name('reason')->value('some text')->type('xsd:string')
=> SOAP::Data->name('globalEntry')->value('1')->type('xsd:boolean')



#=> $soap->call(SOAP::Data->new(name => 'authentication', type => 'xsd1:authenticationType', attr => {})
#=> SOAP::Data->name('version')->value('2')->type('xsd:string')
#=> SOAP::Data->name('customernr')->value('4')->type('xsd:string')
#=> SOAP::Data->name('reference')->value('333')->type('xsd:string')));

=> $soap->call(
         SOAP::Data->name('authentication')->attr(
         SOAP::Data->name('version')->value('2')->type('xsd:string'),
         SOAP::Data->name('customernr')->value('4')->type('xsd:string'),
         SOAP::Data->name('reference')->value('333')->type('xsd:string')
    )));





unless ($data->fault) {
    print $data->result();
  } else {
    print join ', ',
      $data->faultcode,
      $data->faultstring;
  }

I have no idea at this moment how i can create a clean SOAP::Lite call for the needed format.

Any ideas and hints are welcome.

ThanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
#!/usr/bin/perl -w
 
use SOAP::Lite 'trace', 'debug';
 
  my $soap =  SOAP::Lite
    -> proxy('http://servername.company.com/soap')
    -> uri('http://servername.company.com/soap/SoapService.wsdl');
 
 
 
#$soap->call(SOAP::Data->name('addGoodguy')->attr({xmlns => 'http://servername.company.com/soap/'} )
my $data = $soap->call(SOAP::Data->new(name => 'addGoodguy', type => 'xsd1:requestGGType', attr => {})
=> SOAP::Data->name('name')->value('Company Name')->type('xsd:string')
=> SOAP::Data->name('street')->value('Company Street')->type('xsd:string')
=> SOAP::Data->name('city')->value('Company City')->type('xsd:string')
=> SOAP::Data->name('country')->value('Country')->type('xsd:string')
=> SOAP::Data->name('reason')->value('some text')->type('xsd:string')
=> SOAP::Data->name('globalEntry')->value('1')->type('xsd:boolean')
 
 
 
#=> $soap->call(SOAP::Data->new(name => 'authentication', type => 'xsd1:authenticationType', attr => {})
#=> SOAP::Data->name('version')->value('2')->type('xsd:string')
#=> SOAP::Data->name('customernr')->value('4')->type('xsd:string')
#=> SOAP::Data->name('reference')->value('333')->type('xsd:string')));
 
=> $soap->call(
         SOAP::Data->name('authentication')->attr(
         SOAP::Data->name('version')->value('2')->type('xsd:string'),
         SOAP::Data->name('customernr')->value('4')->type('xsd:string'),
         SOAP::Data->name('reference')->value('333')->type('xsd:string')
    )));
 
 
 
 
 
unless ($data->fault) {
    print $data->result();
  } else {
    print join ', ',
      $data->faultcode,
      $data->faultstring;
  }
[+][-]06.25.2008 at 05:49AM PDT, ID: 21864938

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 03:04AM PDT, ID: 21914769

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628