Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: SOAP - Returning response from Server to Client request based on the <Action>

by chanakya (Friar)
on Apr 06, 2005 at 10:30 UTC ( [id://445234]=note: print w/replies, xml ) Need Help??


in reply to Re: SOAP - Returning response from Server to Client request based on the <Action>
in thread SOAP - Returning response from Server to Client request based on the <Action>

jhorcule, first of all thanks for insisting on "use strict" pragma. In every program, I make it a point to use "strict" and "warning" pragmas, Here I left it go somehow.

The modified "byName sub" in your server code, gave what I was looking for.
"Warn" also helped me to check the structure of the document passed to the server.

Regarding the custom serializer,I've implemented the serializer and deserializer on both client/server ends which looks as below:
#Client my $uri = 'Delivery'; my $serializer = DataSerializer->new; print $res->fault ? $res->faultstring. "\n" : $res->result; BEGIN{ package DataSerializer; @DataSerializer::ISA = 'SOAP::Serializer'; sub xmlize { my $self = shift; my($name, $attrs, $values, $id) = @{+shift}; $attrs ||= {}; # keep only namespace attributes for all elements my $a = $attrs->{xmlns} ? {xmlns => $attrs->{xmlns}} : {}; return $self->SUPER::xmlize([$name, $a, $values, $id]); } sub envelope { $_[2] = (UNIVERSAL::isa($_[2] => 'SOAP::Data') ? $_[2] : SOAP::Data->name($_[2])->attr({xmlns => $uri})) if $_[1] =~ /^(?:method|response)$/; shift->SUPER::envelope(@_); } } #End BEGIN block #SERVER SOAP::Transport::HTTP::CGI -> dispatch_to($uri) -> serializer(DataSerializer->new) -> handle; package DataSerializer; @DataSerializer::ISA = 'SOAP::Serializer'; sub xmlize { my $self = shift; my($name, $attrs, $values, $id) = @{+shift}; $attrs ||= {}; # keep only namespace attributes for all elements my $a = $attrs->{xmlns} ? {xmlns => $attrs->{xmlns}} : {}; return $self->SUPER::xmlize([$name, $a, $values, $id]); } sub envelope { $_[2] = (UNIVERSAL::isa($_[2] => 'SOAP::Data') ? $_[2] : SOAP::Data->name($_[2])->attr({xmlns => $uri})) if $_[1] =~ /^(?:method|response)$/; shift->SUPER::envelope(@_); } } #End BEGIN block
Do you think that the above serializer/deserializer is sufficient or any changes need to be made..

I also wanted to ask one question regarding the XMLschema . I'd like to change the schema definition to '2001', currently the generated SOAP envelope returns xmlns as '1999'.
Thanks once again for your suggestions.
  • Comment on Re^2: SOAP - Returning response from Server to Client request based on the <Action>
  • Download Code

Replies are listed 'Best First'.
Re^3: SOAP - Returning response from Server to Client request based on the <Action>
by jhourcle (Prior) on Apr 06, 2005 at 11:23 UTC

    From the looks of things, you're serializing in the document/literal style, as opposed to RPC/encoded. The only thing that I can think of is that you might get some oddities from multiple references to the same object. (but you'd know the data you're sending out better than others, and you may not ever pass that sort of thing)

    As for the XML Schema 2001, I think all that you need to do is to inherit from SOAP::XMLSchema2001::Serializer rather than SOAP::Serializer in your serializer. (but I've never tried doing that).

Re^3: SOAP - Returning response from Server to Client request based on the <Action>
by gellyfish (Monsignor) on Apr 06, 2005 at 11:37 UTC

    The differing namespaces determine the SOAP version, the '1999' versions specify SOAP 1.1, you can set the version to 1.2 using the soapversion() method of SOAP::Lite

    /J\

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found