2015-12-02 53 views
1

我有一個SOAP響應的問題,我希望有人能幫助我。SOAP :: Lite(WSDL)響應不正確反序列化(參考文獻)

當SOAP-Response被SOAP :: Lite模塊反序列化時,我認爲出了問題。在SOAP-Response中有一些「正常」的節點和被引用的節點。但不是正確的反序列化。

SOAP-響應:

<?xml version="1.0" encoding="UTF-8" ?> 
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<SOAP-ENV:Body> 
<ns1:SOAP_GetFirmenlisteResponse xmlns:ns1="http://www.4d.com/namespace/default"> 
    <ERRORNUM xsi:type="xsd:int">0</ERRORNUM> 
    <ERRORTEXT xsi:type="xsd:string"> 
</ERRORTEXT> 
    <LISTE_KDLF_NR_ALS_IDS href="#ref-1"/> <LISTE_SUCHNAMEN href="#ref-2"/> <LISTE_LFD_NR href="#ref-3"/> <LISTE_TIMESTAMP_GEAENDERT href="#ref-4"/> <LISTE_TIMESTAMP_ERZEUGT href="#ref-5"/> 
</ns1:SOAP_GetFirmenlisteResponse> 
<SOAP-ENC:Array id="ref-1" SOAP-ENC:arrayType="xsd:string[4]"> 
<item1>19288</item1> 
<item2>19289</item2> 
<item3>60107</item3> 
<item4>71897</item4> 
</SOAP-ENC:Array> 
<SOAP-ENC:Array id="ref-2" SOAP-ENC:arrayType="xsd:string[4]"> 
<item1>Blabla1</item1> 
<item2>Blabla2</item2> 
<item3>Bla München</item3> 
<item4>Blaürm BÄR</item4> 
</SOAP-ENC:Array> 
<SOAP-ENC:Array id="ref-3" SOAP-ENC:arrayType="xsd:int[4]"> 
<item1>-8423</item1> 
<item2>-8426</item2> 
<item3>-8425</item3> 
<item4>-8428</item4> 
</SOAP-ENC:Array> 
<SOAP-ENC:Array id="ref-4" SOAP-ENC:arrayType="xsd:string[4]"> 
<item1>2015-11-23T09:32:23</item1> 
<item2>2015-11-26T14:55:52</item2> 
<item3>2015-11-26T08:07:26</item3> 
<item4>2015-11-27T09:26:25</item4> 
</SOAP-ENC:Array> 
<SOAP-ENC:Array id="ref-5" SOAP-ENC:arrayType="xsd:string[4]"> 
<item1>2015-11-23T09:30:54</item1> 
<item2>2015-11-26T14:52:06</item2> 
<item3>2015-11-25T10:33:27</item3> 
<item4>2015-11-27T09:24:05</item4> 
</SOAP-ENC:Array> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

結果散列轉儲:

$VAR1 = { 
      'ARRAY(0x2c16e08)' => undef, 
      '0' => '', 
      'ARRAY(0x2f42168)' => [ 
            'Blabla1', 
            'Blabla2', 
            "Bla M\x{fc}nchen", 
            "Bla\x{fc}rm B\x{c4}R" 
           ], 
      'ARRAY(0x2f39680)' => [ 
            '2015-11-23T09:32:23', 
            '2015-11-26T14:55:52', 
            '2015-11-26T08:07:26', 
            '2015-11-27T09:26:25' 
           ] 
     }; 

Perl代碼:

#!/usr/bin/perl 

use Data::Dumper; 
use SOAP::Lite +trace => [ transport => \&log_message ]; 

sub log_message { 
    my ($in) = @_; 
    my ($cont) = $in->content; 
    $cont =~ s/></>\n</g; 
    print "\n-------------------------------------------------\n"; 
    print $cont; 
    print "\n-------------------------------------------------\n"; 
} 

my $soap = SOAP::Lite->service('http://192.168.0.13:8181/4dwsdl'); 

$soap->envprefix('SOAP-ENV'); 
$soap->encprefix('SOAP-ENC'); 
$soap->soapversion('1.1'); 


my %result = $soap->SOAP_GetFirmenliste(
            '00', 
            'SOAPTest', 
            'soaptest', 
            '0000-00-00', 
            '2015-10-01' 
            ); 

print Dumper(\%result); 


exit 0; 

回答

0

我敢肯定您的問題將是這樣的:

my %result = $soap->SOAP_GetFirmenliste(

因爲你print的結果表明,通過這個返回的第一個元件是一個數組引用(這是被轉換爲一個字符串)。

恐怕我不能直接告訴它會回來,由我會建議嘗試:

my $result = $soap -> SOAP_GetFirmenliste( 

然後print Dumper $result

這應該告訴你究竟什麼樣的數據,你得到的結構 - 它不會是一個散列。

+1

謝謝你的提示。我按照你的建議改變了代碼,但現在我只得到'$ VAR1 ='0';'。我認爲'my $ result = $ soap - > SOAP_GetFirmenliste(...'應該是SOAP :: SOM對象的返回值,但事實並非如此。 – SebastianH