Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: jordan.ayers [...] paydia.com
Cc:
AdminCc:

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

Attachments
header_body_test_case.tgz
OutlookEmoji-1471356788247_PastedImage13544a13-c5e0-48d1-9397-a7d830cb088b.png
OutlookEmoji-1471356788247_PastedImageafbede9d-fd88-4317-ae73-3e0603e4ba14.png
OutlookEmoji-1471356788247_PastedImagef0472531-6874-4567-9e2b-6ec10c41dcb1.png
OutlookEmoji-1471356788247_PastedImagef3f9c2cb-e4e4-427c-b849-82f40079f4d7.png



Subject: Issues when request element has properties named 'Header' and 'Body'.
Date: Mon, 25 Sep 2017 22:51:41 +0000
To: "bug-XML-Compile-SOAP [...] rt.cpan.org" <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Jordan Ayers <jordan.ayers [...] paydia.com>
Hi, I've used XML::Compile::SOAP as part of an interface to some unusual SOAP services. While I've been able to interact with most without changes to the module, the built in special handling of 'Header' and 'Body' properties appear to be incompatible with one set of services. I have a patch (copy included below) that covers my needs, but was wondering if an option to disable this behavior on a specific request or action could be added to the module. Basic structure of the needed request: <Envelope><Body> <FooRequest> <Header prop1="a" prop2="b" /> <Body> <Bar>123</Bar> </Body> </FooRequest> </Body></Envelope> Basic structure of client code: my $wsdl = XML::Compile::WSDL11->new('SomeServices.wsdl'); $wsdl->importDefinitions('SomeService.xsd'); my $foo_call = $wsdl->compileClient('Operation_Foo', server => $server_address); my ($res, $trace) = $foo_call->({ Header => { prop1 => 'a', prop2 => 'b' }, Body => { Bar => '123' }, }); But this produces something like: <Envelope><Header /><Body /></Envelope> I also tried using { Body => { FooRequest => { Header => ..., Body => ... } } for the call, but that produced <Envelope><Body /></Envelope>. If there's another way to submit this kind of request, I haven't found it yet. I was only implementing client side code; no testing was done related to generating server code. Issues appear to be only on the message building side of things; I found workarounds for any issues parsing responses without changes to this module. Environment: I'm running this under perl 5.24.2 on CentOS 6. The service files appear to be SOAP 1.1 services (using http://schemas.xmlsoap.org/soap/, http://schemas.xmlsoap.org/soap/encoding/, etc.). The actual wsdl/xsd files are probably under an NDA; if it matters, I could try to put together definition files for the work-alike example above instead. SOAP modules in use for the client code: XML::Compile::WSDL11 3.06 XML::Compile::SOAP, XML::Compile::SOAP11, XML::Compile::Transport::SOAPHTTP (this package, version 3.22) This patch moves the problem from one unlikely name collision to another. A better interface for such a switch would be as an option to $wsdl->compileClient(), but I am not familiar with what would be needed to implement that. This patch allows the following code to produce the desired request: my ($res, $trace) = $foo_call->({ PassHeaderAndBody => {}, Header => { prop1 => 'a', prop2 => 'b' }, Body => { Bar => '123' }, }); diff against XML::Compile::SOAP 3.22: --- a/lib/XML/Compile/SOAP.pm 2017-06-30 03:05:06.000000000 -0600 +++ b/lib/XML/Compile/SOAP.pm 2017-09-25 15:49:04.000000000 -0500 @@ -100,6 +100,9 @@ my $env = $xml->isa('XML::LibXML::Document') ? $xml->documentElement :$xml; my (@header, @body, $wsa_action); +# Add an off switch for this behavior... +my($skip) = $env->getChildrenByLocalName('PassHeaderAndBody'); +if ( !$skip ) { if(my ($header) = $env->getChildrenByLocalName('Header')) { @header = map { $_->isa('XML::LibXML::Element') ? type_of_node($_) : ()} $header->childNodes; @@ -114,6 +117,7 @@ { @body = map { $_->isa('XML::LibXML::Element') ? type_of_node($_) : () } $body->childNodes; } +} +{ header => \@header , body => \@body @@ -177,7 +181,13 @@ || XML::LibXML::Document->new('1.0', $charset || 'UTF-8'); my %data; - $data{$_} = delete $copy{$_} for qw/Header Body/; + # Add an off switch for this behavior... + if ( defined $copy{PassHeaderAndBody} ) { + delete $copy{PassHeaderAndBody}; + } + else{ + $data{$_} = delete $copy{$_} for qw/Header Body/; + } $data{Body} ||= {}; foreach my $label (@$hlabels) Jordan Ayers Chief Software Engineer [1471356788247_PastedImage] Jordan.Ayers@COREcashless.com<mailto:Jordan.Ayers@COREcashless.com> www.COREcashless.com
OutlookEmoji-1471356788247_PastedImagef0472531-6874-4567-9e2b-6ec10c41dcb1.png
CC: ;
Subject: Re: [rt.cpan.org #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Wed, 27 Sep 2017 22:54:02 +0200
To: Jordan Ayers via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Jordan Ayers via RT (bug-XML-Compile-SOAP@rt.cpan.org) [170926 12:34]: Show quoted text
> Mon Sep 25 19:07:46 2017: Request 123126 was acted upon. > Transaction: Ticket created by jordan.ayers@paydia.com > Queue: XML-Compile-SOAP > Subject: Issues when request element has properties named 'Header' and 'Body'.
Show quoted text
> Basic structure of the needed request: > <Envelope><Body> > <FooRequest> > <Header prop1="a" prop2="b" /> > <Body><Bar>123</Bar></Body> > </FooRequest> > </Body></Envelope>
Wow, this tops my long list of broken WSDL designs! Show quoted text
> I also tried using { Body => { FooRequest => { Header => ..., Body => > ... } } for the call, but that produced <Envelope><Body /></Envelope>. > If there's another way to submit this kind of request, I haven't found > it yet.
I think that $wsdl->explain will suggest you to use Body => { Header => ..., Body => ... } Have you tried that? Show quoted text
> The actual wsdl/xsd files are probably under an NDA;
I would keep those WSDLs hidden from the outside world as well ;-) Are you sure that the response is incorrectly decoded? -- 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 #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Wed, 27 Sep 2017 22:27:20 +0000
To: "bug-XML-Compile-SOAP [...] rt.cpan.org" <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Jordan Ayers <jordan.ayers [...] paydia.com>
Mark, Thanks for taking a look. I had missed $wsdl->explain, but it recommends the { Header => ..., Body => ... } approach I started with. Trying the { Body => { Header => ..., Body => ... } } approach also produced <Envelope><Body /><Envelope>. I don't have any known issues on the input parsing side; initial implementation on this was a few years ago (with version 2.26), and between my local demo server not matching the real one, and probably doing a few things the hard way, I expect the complexity in the code there is my fault. It's working without patches and I was going to leave that part alone. But if this request structure is technically allowed but not currently usable, I thought it might be worth checking upstream, rather than carrying my patches forward each dependency update. Other details from $wsdl->explain (equivalent to this): # Describing complex fooNs:FooRequest # is an unnamed complex { # sequence of Header, Body # is an unnamed complex Header => { # list of attributes; mostly strings } # is an unnamed complex Body => { # Sequence of Bar, Bar2 # is a xs:string Bar => "example", # is a xs:string # is optional Bar2 => "example", }, } Jordan Ayers Chief Software Engineer [1471356788247_PastedImage] Jordan.Ayers@COREcashless.com<mailto:Jordan.Ayers@COREcashless.com> www.COREcashless.com
OutlookEmoji-1471356788247_PastedImageafbede9d-fd88-4317-ae73-3e0603e4ba14.png
Subject: Re: [rt.cpan.org #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Thu, 28 Sep 2017 11:56:03 +0200
To: Jordan Ayers via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] nluug.nl>
* Jordan Ayers via RT (bug-XML-Compile-SOAP@rt.cpan.org) [170927 23:01]: Show quoted text
> Queue: XML-Compile-SOAP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=123126 > > > Trying the { Body => { Header => ..., Body => ... } } approach > also produced <Envelope><Body /><Envelope>.
Don't you get any warnings about 'unused tags'? Try "use Log::Report mode => 2;" Show quoted text
> But if this request structure is technically allowed but not currently > usable, I thought it might be worth checking upstream, rather than > carrying my patches forward each dependency update.
I see no reason for your schema not to work, besides the simplification in collecting Header and Body parameters... In XML/Compile/SOAP.pm line 205, you will find two commented lines of code. Uncomment them, and see whether your parameters get unpacked correctly. Show quoted text
> Other details from $wsdl->explain (equivalent to this): > > # Describing complex fooNs:FooRequest > # is an unnamed complex > > { # sequence of Header, Body > # is an unnamed complex > > Header => > { # list of attributes; mostly strings > } > > # is an unnamed complex > Body => > { # Sequence of Bar, Bar2 > # is a xs:string > Bar => "example", > > # is a xs:string > # is optional > Bar2 => "example", > }, }
Yeh, this is as I expected it to be. So this should work: $wsdl->call('...mycall...', Body => { Header => {}, Body => { Bar => 'example', Bar2 => 'example' } }; I expect you eversee another error message, unrelated to the Body/Body problem. -- 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 #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Fri, 29 Sep 2017 15:24:52 +0000
To: "bug-XML-Compile-SOAP [...] rt.cpan.org" <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Jordan Ayers <jordan.ayers [...] paydia.com>
I'm still not able to force the right structure, but I've now put together a test case which exhibits the problem, and uses similar methods to define the service action's body format. Files attached. You should be able to reproduce the issue with this. Results for the various ways suggested so far for issuing the call are included, but none are producing the expected format. Output includes the unused property warnings. Jordan Ayers Chief Software Engineer [1471356788247_PastedImage] Jordan.Ayers@COREcashless.com<mailto:Jordan.Ayers@COREcashless.com> www.COREcashless.com
OutlookEmoji-1471356788247_PastedImage13544a13-c5e0-48d1-9397-a7d830cb088b.png
Download header_body_test_case.tgz
application/x-compressed-tar 1.7k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Sun, 1 Oct 2017 09:44:26 +0200
To: Jordan Ayers via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Mark Overmeer (mark@nluug.nl) [170928 11:56]: Show quoted text
> * Jordan Ayers via RT (bug-XML-Compile-SOAP@rt.cpan.org) [170927 23:01]:
> > Queue: XML-Compile-SOAP > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=123126 > > > > > Trying the { Body => { Header => ..., Body => ... } } approach > > also produced <Envelope><Body /><Envelope>.
Your example helped me a lot. I tried to figure-out what was wrong for quite some time... until I decided to create a version which was nearly the same, but without conflicting names... Actually, fields { A => 1, B => 2 } are not short for Body => { A => 1, B => 2 } and also not short for Body => $operation => { A => 1, B => 2 } but Body => $body_part_name => { A => 1, B => 2 } The reason is that a body can contain more than one part. The structure is equivalent to that of the header components. In your example WSDL, the body part's name is 'part'. Hence: Body => part => { Body => {}, Header => {} } I hope that helps. -- 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 #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Mon, 2 Oct 2017 14:18:41 +0000
To: "bug-XML-Compile-SOAP [...] rt.cpan.org" <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Jordan Ayers <jordan.ayers [...] paydia.com>
I see it in the $wsdl->explain() output now; I had thought '$part' was a library assigned name when I first saw it, and had forgotten that line by the time I was preparing the example. And since I left it out of my earlier post, there wasn't any way for you to see it initially. So it is possible, and the calling style is discoverable (so a control over the calling style won't add any value here). I was chasing the wrong behavior when the short calling style stopped working (header/body handling vs. automatic part name insertion). This set of modules has been very helpful in several service integrations for us; it's good work. Thank you for your time. Jordan Ayers Chief Software Engineer [1471356788247_PastedImage] Jordan.Ayers@COREcashless.com<mailto:Jordan.Ayers@COREcashless.com> www.COREcashless.com
OutlookEmoji-1471356788247_PastedImagef3f9c2cb-e4e4-427c-b849-82f40079f4d7.png
Subject: Re: [rt.cpan.org #123126] Issues when request element has properties named 'Header' and 'Body'.
Date: Tue, 3 Oct 2017 08:46:44 +0200
To: Jordan Ayers via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Jordan Ayers via RT (bug-XML-Compile-SOAP@rt.cpan.org) [171002 14:34]: Show quoted text
> Queue: XML-Compile-SOAP > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=123126 > > > I see it in the $wsdl->explain() output now; I had thought '$part' > was a library assigned name when I first saw it, and had forgotten that > line by the time I was preparing the example. And since I left it out > of my earlier post, there wasn't any way for you to see it initially.
Ten years after the initial implementation, I cannot remember all the weirdness either ;-) The explain text will be a little bit clearer for next release. Show quoted text
>
Thank you for your great example: hunting bugs very important for the quality of code! -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
After a long hunt for the correct solution, we discovered that there is no need for changes in the code.