Loading ...
Sorry, an error occurred while loading the content.

Re: Auto-generated namespaces

Expand Messages
  • Martin McFly
    Duncan, Paul Thanks for the responses. My follow on question is this: my client code accesses a WSDL file like so: $soap =
    Message 1 of 5 , Nov 8, 2002
    • 0 Attachment
      Duncan, Paul

      Thanks for the responses. My follow on question is this: my client
      code accesses a WSDL file like so:

      $soap =
      SOAP::Lite->service('http://localhost/scripts/WSDL/Interop/InteropTest.wsdl');
      ..... #initialize @val and pass it to the service
      $res = $soap->echoStructArray(\@val);

      If "brook" is defined in my WSDL, shouldn't this be sufficient? It
      appears that even if "brook" is defined and has it's own namespace,
      SOAP::Lite still generates "namespaces.soaplite.com/perl" in the
      response. So far, the only way I've been able to get my WSDL to agree
      with the returned SOAP is to put "brook" in the
      "namespaces.soaplite.com/perl" namespace.

      In a follow-on to this post, Paul said I can use the maptype method to
      specify my own namespaces. I see where I can do this for the request
      (I could just add $soap->maptype(...) into the code above), but how do
      I use maptype to change the namespace of the response? Do I need to
      rewrite my CGI server to somehow manipulate the namespaces in the SOAP
      envelope? Or can I somehow add it to my echoStructArray code?

      Thanks

      --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
      > On 2002-11-07 Martin McFly wrote:
      > >Another question:
      > >
      > >Is there a way to control the namespaces generated in a SOAP
      envelope?
      > >
      > >I've noticed that SOAP::Lite as a server (I used the extremely simple
      > >CGI server example) generates namespaces automatically to some degree.
      > > For example, I have a server that dispatches to a .pm with the
      > >following code:
      > >
      > >Server code:
      > >
      > >use SOAP::Transport::HTTP;
      > >
      > >$obj = SOAP::Transport::HTTP::CGI->new();
      > >$obj->dispatch_to('c:/Inetpub/Scripts/WSDL/Interop', 'Interop',
      > >'Interop::echoStructArray')
      > > -> handle;
      > >
      > >Package code:
      > >
      > >sub echoStructArray {
      > > my $self = shift;
      > > my $input = shift;
      > > $val[0] = SOAP::Data->type("SOAPStruct")->value({"varInt"=>1,
      > >"varFloat"=>1.1, "varString"=>"summ 1"});
      > > $val[1] = SOAP::Data->type("SOAPStruct")->value({"varInt"=>22,
      > >"varFloat"=>22.22, "varString"=>"summ 22"});
      > > $val[2] = SOAP::Data->type("SOAPStruct")->value({"varInt"=>333,
      > >"varFloat"=>333.33, "varString"=>"summ 333"});
      > > return SOAP::Data->name("return" => \@val);
      > >}
      > >
      > >This results in the following SOAP being returned:
      > >
      > ><?xml version="1.0" encoding="UTF-8"?>
      > ><SOAP-ENV:Envelope
      > >xmlns:namesp2="http://xml.apache.org/xml-soap"
      > >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      > >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      > ><SOAP-ENV:Body>
      > ><namesp1:echoStructArrayResponse
      xmlns:namesp1="http://localhost/Interop">
      > ><return SOAP-ENC:arrayType="namesp2:SOAPStruct[3]"
      > >xsi:type="SOAP-ENC:Array">
      > ><item xsi:type="namesp2:SOAPStruct">
      > ><varFloat xsi:type="xsd:float">1.1</varFloat>
      > ><varString xsi:type="xsd:string">summ 1</varString>
      > ><varInt xsi:type="xsd:int">1</varInt>
      > ></item> etc....
      > >
      > >The thing that is puzzling me is where namesp2 came from. SOAP::Lite
      > >seems to have auto-generated this namespace of
      > >"xml.apache.org/xml-soap", and used it throughout the SOAP response.
      >
      > SOAPStruct is associated automatically with the xml.apache.org/xml-soap
      > namespace. If you don't want that namespace then don't use
      > type('SOAPStruct') or type it as something else. What is appropriate
      > depends on your destination system.
      >
      > >Thus, if I were writing a WSDL file, I would be forced to use
      > >"xml.apache.org/xml-soap" in order for my namespaces to agree.
      > >
      > >Similarly, if I change my .pm file to the following (all I'm doing is
      > >changing "SOAPStruct" to an arbitrary name "brook"):
      > >
      > >sub echoStructArray {
      > > my $self = shift;
      > > my $input = shift;
      > > $val[0] = SOAP::Data->type("brook")->value({"varInt"=>1,
      > >"varFloat"=>1.1, "varString"=>"summ 1"});
      > > $val[1] = SOAP::Data->type("brook")->value({"varInt"=>22,
      > >"varFloat"=>22.22, "varString"=>"summ 22"});
      > > $val[2] = SOAP::Data->type("brook")->value({"varInt"=>333,
      > >"varFloat"=>333.33, "varString"=>"summ 333"});
      > > return SOAP::Data->name("return" => \@val);
      > >}
      > >
      > >then the resulting SOAP response is:
      > >
      > ><?xml version="1.0" encoding="UTF-8"?>
      > ><SOAP-ENV:Envelope
      > >xmlns:namesp2="http://namespaces.soaplite.com/perl"
      > >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      > >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      > ><SOAP-ENV:Body>
      > ><namesp1:echoStructArrayResponse
      > >xmlns:namesp1="http://localhost/Interop">
      > ><return SOAP-ENC:arrayType="namesp2:brook[3]"
      xsi:type="SOAP-ENC:Array">
      > ><item .... etc.
      > >
      > >Notice in this example that namesp2 has now changed to
      > >"namespaces.soaplite.com/perl"!!! How can I control what namespace is
      > >generated in the envelope? I'm sure there's a simple answer to this
      > >question, I just haven't been able to figure it out.
      >
      > Now you have specified a type of 'brook' without any definition of
      > what that type is. SOAP::Lite has to put it in a namespace so has
      > put it in its own one.
      >
      > If you're confused by this then you probably need to clarify what
      > your destination system is expecting.
      >
      > Regards,
      > Duncan Cameron
    • Martin McFly
      Hello- I still haven t figured out a solution to my problem. If I m using SOAP::Lite as a CGI server (using the dispatch_to method), and my object (called by
      Message 2 of 5 , Nov 14, 2002
      • 0 Attachment
        Hello-

        I still haven't figured out a solution to my problem. If I'm using
        SOAP::Lite as a CGI server (using the dispatch_to method), and my
        object (called by CGI server) contains the following:

        sub echoString {
        my $self = shift;
        my $input = shift;
        $val[0] = SOAP::Data->type("brook")->value({"varInt"=>1,
        "varFloat"=>1.1, "varString"=>"summ 1"});
        $val[1] = SOAP::Data->type("brook")->value({"varInt"=>22,
        "varFloat"=>22.22, "varString"=>"summ 22"});
        $val[2] = SOAP::Data->type("brook")->value({"varInt"=>333,
        "varFloat"=>333.33, "varString"=>"summ 333"});
        return SOAP::Data->name("return" => \@val);
        }

        I don't know where to define "brook". If I have "brook" defined in
        the WSDL and I use a SOAP::Lite client:

        $soap = SOAP::Lite->service("wsdl_file.wsdl");
        $soap->echoString(...);

        The server still puts "brook" in "namespaces.soaplite.com/perl". If I
        can use the maptype method to change that, where do I use it? In my
        CGI server that handles the dispatch? Or in my .pm that is called by
        the dispatcher? Or do I need to rewrite my CGI server entirely?

        I'd even be willing to write all this up into some kind of tutorial if
        somebody can tell me what needs to be done!

        Thanks.





        --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
        > On 2002-11-07 Martin McFly wrote:
        > >Another question:
        > >
        > >Is there a way to control the namespaces generated in a SOAP
        envelope?
        > >
        > >I've noticed that SOAP::Lite as a server (I used the extremely simple
        > >CGI server example) generates namespaces automatically to some degree.
        > > For example, I have a server that dispatches to a .pm with the
        > >following code:
        > >
        > >Server code:
        > >
        > >use SOAP::Transport::HTTP;
        > >
        > >$obj = SOAP::Transport::HTTP::CGI->new();
        > >$obj->dispatch_to('c:/Inetpub/Scripts/WSDL/Interop', 'Interop',
        > >'Interop::echoStructArray')
        > > -> handle;
        > >
        > >Package code:
        > >
        > >sub echoStructArray {
        > > my $self = shift;
        > > my $input = shift;
        > > $val[0] = SOAP::Data->type("SOAPStruct")->value({"varInt"=>1,
        > >"varFloat"=>1.1, "varString"=>"summ 1"});
        > > $val[1] = SOAP::Data->type("SOAPStruct")->value({"varInt"=>22,
        > >"varFloat"=>22.22, "varString"=>"summ 22"});
        > > $val[2] = SOAP::Data->type("SOAPStruct")->value({"varInt"=>333,
        > >"varFloat"=>333.33, "varString"=>"summ 333"});
        > > return SOAP::Data->name("return" => \@val);
        > >}
        > >
        > >This results in the following SOAP being returned:
        > >
        > ><?xml version="1.0" encoding="UTF-8"?>
        > ><SOAP-ENV:Envelope
        > >xmlns:namesp2="http://xml.apache.org/xml-soap"
        > >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        > >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        > >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        > ><SOAP-ENV:Body>
        > ><namesp1:echoStructArrayResponse
        xmlns:namesp1="http://localhost/Interop">
        > ><return SOAP-ENC:arrayType="namesp2:SOAPStruct[3]"
        > >xsi:type="SOAP-ENC:Array">
        > ><item xsi:type="namesp2:SOAPStruct">
        > ><varFloat xsi:type="xsd:float">1.1</varFloat>
        > ><varString xsi:type="xsd:string">summ 1</varString>
        > ><varInt xsi:type="xsd:int">1</varInt>
        > ></item> etc....
        > >
        > >The thing that is puzzling me is where namesp2 came from. SOAP::Lite
        > >seems to have auto-generated this namespace of
        > >"xml.apache.org/xml-soap", and used it throughout the SOAP response.
        >
        > SOAPStruct is associated automatically with the xml.apache.org/xml-soap
        > namespace. If you don't want that namespace then don't use
        > type('SOAPStruct') or type it as something else. What is appropriate
        > depends on your destination system.
        >
        > >Thus, if I were writing a WSDL file, I would be forced to use
        > >"xml.apache.org/xml-soap" in order for my namespaces to agree.
        > >
        > >Similarly, if I change my .pm file to the following (all I'm doing is
        > >changing "SOAPStruct" to an arbitrary name "brook"):
        > >
        > >sub echoStructArray {
        > > my $self = shift;
        > > my $input = shift;
        > > $val[0] = SOAP::Data->type("brook")->value({"varInt"=>1,
        > >"varFloat"=>1.1, "varString"=>"summ 1"});
        > > $val[1] = SOAP::Data->type("brook")->value({"varInt"=>22,
        > >"varFloat"=>22.22, "varString"=>"summ 22"});
        > > $val[2] = SOAP::Data->type("brook")->value({"varInt"=>333,
        > >"varFloat"=>333.33, "varString"=>"summ 333"});
        > > return SOAP::Data->name("return" => \@val);
        > >}
        > >
        > >then the resulting SOAP response is:
        > >
        > ><?xml version="1.0" encoding="UTF-8"?>
        > ><SOAP-ENV:Envelope
        > >xmlns:namesp2="http://namespaces.soaplite.com/perl"
        > >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        > >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        > >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        > ><SOAP-ENV:Body>
        > ><namesp1:echoStructArrayResponse
        > >xmlns:namesp1="http://localhost/Interop">
        > ><return SOAP-ENC:arrayType="namesp2:brook[3]"
        xsi:type="SOAP-ENC:Array">
        > ><item .... etc.
        > >
        > >Notice in this example that namesp2 has now changed to
        > >"namespaces.soaplite.com/perl"!!! How can I control what namespace is
        > >generated in the envelope? I'm sure there's a simple answer to this
        > >question, I just haven't been able to figure it out.
        >
        > Now you have specified a type of 'brook' without any definition of
        > what that type is. SOAP::Lite has to put it in a namespace so has
        > put it in its own one.
        >
        > If you're confused by this then you probably need to clarify what
        > your destination system is expecting.
        >
        > Regards,
        > Duncan Cameron
      Your message has been successfully submitted and would be delivered to recipients shortly.