Skip Menu |

This queue is for tickets about the XML-Compile-SOAP CPAN distribution.

Report information
The Basics
Id: 105170
Status: resolved
Priority: 0/
Queue: XML-Compile-SOAP

People
Owner: Nobody in particular
Requestors: NWELLNHOF [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 3.08
Fixed in: (no value)



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
Subject: Re: [rt.cpan.org #105170] "data not recognized" when parsing Encoded RPC response
Date: Thu, 11 Jun 2015 13:38:48 +0200
To: Nick Wellnhofer via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Nick Wellnhofer via RT (bug-XML-Compile-SOAP@rt.cpan.org) [150611 11:01]: Show quoted text
> error: data not recognized, found a `return' at /SOAP-ENV:Envelope/...
Show quoted text
> <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>
Remove the <return> wrapper and see that it works. Now, at first sight, I think that your expectations are correct. However, I need a second sight on the issue ;-) There are people successfully using this module for SOAP::RPC (although support is rather young, and I hate SOAP-RPC) So: I'll investigate deeper after lunch. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
On Thu Jun 11 07:39:06 2015, solutions@overmeer.net wrote: Show quoted text
> Remove the <return> wrapper and see that it works.
Yes, removing the <return> wrapper works. Show quoted text
> Now, at first sight, > I think that your expectations are correct.
I think the server response is valid. Here are some snippets from the WSDL: <portType name="SoapApiPort"> <operation name="GetServerTime"> <input message="tns:GetServerTimeIn"/> <output message="tns:GetServerTimeOut"/> </operation> </portType> <binding name="SoapApiBinding" type="tns:SoapApiPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetServerTime"> <soap:operation soapAction="http://example.com/api/"/> <input> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://example.com/api/"/> </input> <output> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://example.com/api/"/> </output> </operation> </binding> <message name="GetServerTimeOut"> <part name="return" type="tns:SoapResponse_GetServerTime"/> </message> Show quoted text
> So: I'll investigate deeper after lunch.
Thanks!
Subject: Re: [rt.cpan.org #105170] "data not recognized" when parsing Encoded RPC response
Date: Fri, 12 Jun 2015 15:20:50 +0200
To: Nick Wellnhofer via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Nick Wellnhofer via RT (bug-XML-Compile-SOAP@rt.cpan.org) [150611 13:57]: I have located the cause... some namespace trouble in the decoder. sub _dec_typed($$$) { my ($self, $node, $type, $index) = @_; my ($prefix, $local) = $type =~ m/^(.*?)\:(.*)/ ? ($1, $2) : ('',$type); ! my $ns = $node->lookupNamespaceURI($prefix) // ''; ! my $exp = pack_type $ns, $local; ! my $full = type_of_node $node; ! my $read = $self->schemas->compileType(READER => $exp, element => $full); my $child = $read->($node); my $data = ref $child eq 'HASH' ? $child : { _ => $child }; ! $data->{_TYPE} = $exp; ! $data->{_NAME} = $full; my $id = $node->getAttribute('id'); $data->{id} = $id if defined $id; I have to investigate the other locations where _dec_reader is being used: those probably have to be changed as well. After that, I'll probably make a release. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Subject: Re: [rt.cpan.org #105170] "data not recognized" when parsing Encoded RPC response
Date: Fri, 12 Jun 2015 15:31:09 +0200
To: bug-XML-Compile-SOAP [...] rt.cpan.org
From: Nick Wellnhofer <wellnhofer [...] aevum.de>
On 12/06/2015 15:21, Mark Overmeer via RT wrote: Show quoted text
> I have to investigate the other locations where _dec_reader is being > used: those probably have to be changed as well. After that, I'll > probably make a release.
The following code in XML::Compile::SOAP11::Encoding->_dec_reader looks weird to me: if( $typens ne $schemans && !$self->schemas->namespaces->find(element => $type)) { # work-around missing element $self->schemas->importDefinitions(<<__FAKE_SCHEMA); <schema xmlns="$schemans" targetNamespace="$typens" xmlns:d="$typens"> <element name="$typelocal" type="d:$typelocal" /> </schema> __FAKE_SCHEMA } An xsd:element with the name of a type? Nick
Subject: Re: [rt.cpan.org #105170] "data not recognized" when parsing Encoded RPC response
Date: Fri, 12 Jun 2015 15:39:16 +0200
To: "wellnhofer [...] aevum.de via RT" <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* wellnhofer@aevum.de via RT (bug-XML-Compile-SOAP@rt.cpan.org) [150612 13:31]: Show quoted text
> Queue: XML-Compile-SOAP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105170 > > > On 12/06/2015 15:21, Mark Overmeer via RT wrote:
> > I have to investigate the other locations where _dec_reader is being > > used: those probably have to be changed as well. After that, I'll > > probably make a release.
> > The following code in XML::Compile::SOAP11::Encoding->_dec_reader looks weird > to me: > > if( $typens ne $schemans > && !$self->schemas->namespaces->find(element => $type)) > { # work-around missing element > $self->schemas->importDefinitions(<<__FAKE_SCHEMA); > <schema xmlns="$schemans" targetNamespace="$typens" xmlns:d="$typens"> > <element name="$typelocal" type="d:$typelocal" /> > </schema> > __FAKE_SCHEMA > } > > An xsd:element with the name of a type?
It is the part of the code which is to be replaced by the smarter X::C::Schema::compileType() The problem is that the basic code translates XML::LibXML::Element's into HASHes. So, as long as you have a clear element declaration in a schema, it all works well... However, ugly soap-rpc does not always cleanly specify elements to be included into the messages, only their types. Therefore, I have to use a trick to generate an element declaration with the right name and type. The SOAP-RPC code became available quite recently, but is based on quite old code. Inbetween, I added the compileType() method in the main code... but that improvement did not reach the new soap-rpc as it should have. -- Regards, MarkOv ------------------------------------------------------------------------ drs Mark A.C.J. Overmeer MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Subject: Re: [rt.cpan.org #105170] "data not recognized" when parsing Encoded RPC response
Date: Mon, 15 Jun 2015 00:47:57 +0200
To: Nick Wellnhofer via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] nluug.nl>
* Nick Wellnhofer via RT (bug-XML-Compile-SOAP@rt.cpan.org) [150611 13:57]: Show quoted text
> Queue: XML-Compile-SOAP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105170 >
Hey, I have tried to fix encoding a but, but am not really sure about it: no way/time to test it. Maybe you can try to use it? Do you have an email address for me to send the alpha release? -- MarkOv ------------------------------------------------------------------------ drs Mark A.C.J. Overmeer MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Subject: Re: [rt.cpan.org #105170] "data not recognized" when parsing Encoded RPC response
Date: Mon, 15 Jun 2015 11:59:15 +0200
To: bug-XML-Compile-SOAP [...] rt.cpan.org
From: Nick Wellnhofer <wellnhofer [...] aevum.de>
On 15/06/2015 00:48, Mark Overmeer via RT wrote: Show quoted text
> I have tried to fix encoding a but, but am not really sure about it: > no way/time to test it. Maybe you can try to use it? Do you have > an email address for me to send the alpha release?
Yes, I'd like to test your changes. You can send them to wellnhofer [...] aevum.de Nick
probably resolved in 3.09, to be released later today