Leser: 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Data::Dumper; use SOAP::Lite; my %data_to_send_in_soap_map = ( 'country' => 'NL', 'step' => '1', ); my (@soap_map,@params); foreach my $key (keys %data_to_send_in_soap_map) { push @soap_map, \SOAP::Data -> name ('item') -> value ( SOAP::Data -> name ($key) -> value ($data_to_send_in_soap_map{$key}), ) ; } @params = ( SOAP::Data -> name ('params') -> value (@soap_map) ); print Dumper (\@params);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Data::Dumper; use SOAP::Lite; my %data_to_send_in_soap_map = ( 'country' => 'NL', 'step' => '1', ); my (@soap_map,@params); foreach my $key (keys %data_to_send_in_soap_map) { push @soap_map, \SOAP::Data -> name ('item') -> value ([ SOAP::Data -> name ($key) -> value ($data_to_send_in_soap_map{$key}), ]) ; } @params = ( SOAP::Data -> name ('params') -> value (@soap_map) ); print Dumper (\@params);
1
2
3
4
5
6
7
8
9
10
<params xsi:type="ns2: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>
Quote- Der Parameter für SOAP::Data->value($param) muss immer eine
Referenz sein - entweder eine Array-Referenz [] oder eine Referenz auf
ein Objekt ...
Guest bianca
\SOAP::Data -> name ($key) -> value ($data_to_send_in_soap_map{$key}),
SOAP::Data -> name ('params') -> value(\@soap_map);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; use SOAP::Lite; my %data_to_send_in_soap_map = ( 'country' => 'NL', 'step' => '1', ); my (@soap_map,@params); foreach my $key (keys %data_to_send_in_soap_map) { push @soap_map, \SOAP::Data->name('item')->value([ SOAP::Data->name('key')->value($key), SOAP::Data->name('value')->value($data_to_send_in_soap_map{$key}) ]); } @params = ( SOAP::Data->name('params')->type('ns2:Map')->value(\@soap_map) ); print Dumper (\@params);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="ht
tp://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xml
soap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<foo>
<params><c-gensym3>
<item>
<key>country</key>
<value>NL</value>
</item>
</c-gensym3>
<c-gensym4>
<item>
<key>step</key>
<value>1</value>
</item>
</c-gensym4>
</params>
</foo>
</soap:Body>
</soap:Envelope>
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
#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; use SOAP::Lite +trace => 'all'; my $soap = SOAP::Lite->proxy('http://binnicihtda:8080')->autotype(0); my %data_to_send_in_soap_map = ( 'country' => 'NL', 'step' => '1', ); my (@soap_map,@params); foreach my $key (keys %data_to_send_in_soap_map) { push @soap_map, \SOAP::Data->name('item')->value([ SOAP::Data->name('key')->value($key), SOAP::Data->name('value')->value($data_to_send_in_soap_map{$key}) ]); } @params = ( SOAP::Data->name('params')->type('ns2:Map')->value(\@soap_map) ); print Dumper (\@params); $soap->call('foo',@params);
1
2
3
4
5
6
7
SOAPAction: "#foo"
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="ht
tp://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xml
soap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><foo><params><c-gensym3><item><ke
y>country</key><value>NL</value></item></c-gensym3><c-gensym4><item><key>step</key><value>1</value></item></c-gensym4></para
ms></foo></soap:Body></soap:Envelope>
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>
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'), );
1 2 3 4 5 6 7 8 9
foreach my $key (keys %data_to_send_in_soap_map) { push @soap_map,[ SOAP::Data->name('key')->value($key), SOAP::Data->name('value')->value($data_to_send_in_soap_map{$key}) ]; } @params = ( SOAP::Data->name('params')->type('ns2:Map')->value(\@soap_map) );