Thread Datenstruktur mit SOAP::Data (4 answers)
Opened by bianca at 2010-06-13 17:32

topeg
 2010-06-14 13:34
#138308 #138308
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Sei froh das ich etwas Zeit hatte... :-)

Das sieht doch nicht schlecht aus:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>
<get_form xmlns="http://dev.iban-bic.com/Riban/soap2/?wsdl">
<params soapenc:arrayType="xsd:anyType[2]" xsi:type="tns:Map">
<item>
<key xsi:type="xsd:string">country</key>
<value xsi:type="xsd:string">NL</value>
</item>
<item>
<key xsi:type="xsd:string">step</key>
<value xsi:type="xsd:string">1</value>
</item>
</params>
<user xsi:type="xsd:string">name</user>
<password xsi:type="xsd:string">pass</password>
</get_form>
</soap:Body>
</soap:Envelope>


Code:
Code (perl): (dl )
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
#!/usr/bin/perl
use strict;
use warnings;

sub BEGIN
{ unshift(@INC,'.'); }

use Data::Dumper;
use SOAP::Lite +trace => 'all';


my $soap = SOAP::Lite ->uri( 'http://dev.iban-bic.com/Riban/soap2/?wsdl' );
$soap->proxy( 'http://bla.home:8888' );
#$soap->proxy('http://dev.iban-bic.com/Riban/soap2/');

my %data_to_send_in_soap_map = (
  'country' => 'NL',
  'step' => '1',
);

my $user='name';
my $pass='pass';

my (@soap_map,@params);
foreach my $key (keys %data_to_send_in_soap_map) {
  push @soap_map,
    \SOAP::Data->value(
      SOAP::Data->name('key'   => $key                           )->type('xsd:string'),
      SOAP::Data->name('value' => $data_to_send_in_soap_map{$key})->type('xsd:string'),
    );
}

$soap->get_form(
  SOAP::Data->name('params'   => \@soap_map)->type('tns:Map'),
  SOAP::Data->name('user'     => $user     )->type('xsd:string'),
  SOAP::Data->name('password' => $pass     )->type('xsd:string'),
);


Das setzen der Typen ist nicht zwingend aber ich weiß nicht wie genau es der Server nimmt.

View full thread Datenstruktur mit SOAP::Data