Subject: | "data not recognized" when parsing Encoded RPC response |
I get an error message like the following when parsing responses from an Encoded RPC service:
error: data not recognized, found a `return' at /SOAP-ENV:Envelope/...
I'm actually using XML::Compile::WSDL, but I found it too complicated to write a test case that uses parts of my WSDL file and emulates a server. So I attached a reduced test case that calls XML::Compile::SOAP->_receiver with the same parameters that I get from XML::Compile::WSDL.
Subject: | bug.pl |
use strict;
use warnings;
use XML::Compile::SOAP11::Client;
use XML::Compile::SOAP11::Encoding;
my $client = XML::Compile::SOAP11::Client->new;
$client->schemas->importDefinitions(<<'SCHEMA');
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/api/">
<xsd:complexType name="SoapResponse_GetServerTime">
<xsd:all>
<xsd:element name="Timestamp" type="xsd:int" minOccurs="0" nillable="true" maxOccurs="1"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
SCHEMA
my $decode_response = $client->_receiver(
kind => 'request-response',
style => 'rpc',
body => {
use => 'encoded',
procedure => '{http://example.com/api/}GetServerTimeResponse',
parts => [ {
name => 'return',
type => '{http://example.com/api/}SoapResponse_GetServerTime',
} ],
},
);
my $answer = $decode_response->(<<'RESPONSE');
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://example.com/api/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:GetServerTimeResponse>
<return xsi:type="ns1:SoapResponse_GetServerTime">
<Timestamp xsi:type="xsd:int">1434017134</Timestamp>
</return>
</ns1:GetServerTimeResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
RESPONSE