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

Re: [soaplite] .NET/Axis clients and SOAP::Lite server

Expand Messages
  • Andrew Bayliss
    On 6/10/06, Chris Dent wrote: ... It seems that in all my fiddling about, I didn t properly test the most obvious solution, which was
    Message 1 of 5 , Jun 12, 2006
    • 0 Attachment
      On 6/10/06, Chris Dent <cdent@...> wrote:
      ...
      > I've based my wsdl on google's so I'm assuming that it's something close
      > to "right", but that may be bad thinking.
      >
      > Let me know if you learn something and thanks for the shortcut.

      It seems that in all my fiddling about, I didn't properly test the
      most obvious solution, which was to call ns() with the namespace I'm
      using :(

      The following script returns results that are correctly picked up by
      .NET, Axis and SOAP::Lite clients. I'd be interested to know if this
      also works with jwsdp, or anything else for that matter.

      #!/usr/bin/perl -w

      use strict;

      use SOAP::Lite;
      use SOAP::Transport::HTTP;

      use constant NS => 'urn:Test';

      my $lather = new SOAP::Transport::HTTP::CGI();
      $lather->dispatch_to('Test');
      $lather->serializer()->ns(NS);
      $lather->handle();

      package Test;

      sub Test {

      return(
      SOAP::Data->name('output_one' => "one"),
      SOAP::Data->name('output_two' => "two"),
      SOAP::Data->name('output_three' => "three"),
      );
      }
    • Kevin Stone
      I notice a xmlns:soap= http://schemas.xmlsoap.org/wsdl/soap/ If you take your wsdl and do cat my.wsdl | sed -e s/soap:/other:/g | sed -e s/xmlns:soap/
      Message 2 of 5 , Jun 12, 2006
      • 0 Attachment
        I notice a 

        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

        If you take your wsdl and do

        cat my.wsdl | sed -e s/soap:/other:/g | sed -e s/xmlns:soap/xmlns:other/g > new.wsdl

        (to change all of the soap: namespace prefix to something different...)

        You can then use

        #!/usr/bin/perl

        use SOAP::Lite;
        use Data::Dumper;

        my $client = SOAP::Lite->service("new.wsdl");
        my $ret = $client->myfunction( 1, "someotherparameter" );
        print Dumper $ret;

        and avoid a lot of hassle...

        On Jun 9, 2006, at 11:30 AM, Andrew Bayliss wrote:

        Hi,

        I'm currently trying to get both .NET and Java (Apache AXIS) clients
        to work with a SOAP::Lite server. I've done what the documentation
        says regarding explicitly setting the namespace on returned values,
        i.e.

        return(
        SOAP::Data-> name('output_ one' => "one")->uri( "urn:Test" ),
        SOAP::Data-> name('output_ two' => "two")->uri( "urn:Test" ),
        SOAP::Data-> name('output_ three' => "three")->uri( "urn:Test" ),
        );

        producing the XML:

        <soap:Envelope soap:encodingStyle= "http://schemas. xmlsoap.org/ soap/encoding/"
        xmlns:soap="http://schemas. xmlsoap.org/ soap/envelope/"
        xmlns:soapenc= "http://schemas. xmlsoap.org/ soap/encoding/"
        xmlns:xsd="http://www.w3. org/2001/ XMLSchema"
        xmlns:xsi="http://www.w3. org/2001/ XMLSchema- instance">
        <soap:Body>
        <TestResponse xmlns="urn:Test" >
        <namesp1:output_ one xsi:type="xsd: string"
        xmlns:namesp1= "urn:Test" >one</namesp1: output_one>
        <namesp2:output_ two xsi:type="xsd: string"
        xmlns:namesp2= "urn:Test" >two</namesp2: output_two>
        <namesp3:output_ three xsi:type="xsd: string"
        xmlns:namesp3= "urn:Test" >three</namesp3: output_three>
        </TestResponse>
        </soap:Body>
        </soap:Envelope>

        but, apart from seeming needlessly verbose, this doesn't work. Axis
        receives no returned parameters, and .NET only gets the first one.

        After some fiddling around with the various namespace methods in
        SOAP::Lite (default_ns, register_ns) the only way I've managed to get
        it to work is to call ->serializer( )->ns('') on the server before
        handling the SOAP call (with no explicit namespace on each return
        value). This produces the XML:

        <soap:Envelope soap:encodingStyle= "http://schemas. xmlsoap.org/ soap/encoding/"
        xmlns:namesp2= "urn:Test"
        xmlns:soap="http://schemas. xmlsoap.org/ soap/envelope/"
        xmlns:soapenc= "http://schemas. xmlsoap.org/ soap/encoding/"
        xmlns:xsd="http://www.w3. org/2001/ XMLSchema"
        xmlns:xsi="http://www.w3. org/2001/ XMLSchema- instance">
        <soap:Body>
        <namesp2:TestRespon se>
        <output_one xsi:type="xsd: string">one< /output_one>
        <output_two xsi:type="xsd: string">two< /output_two>
        <output_three xsi:type="xsd: string">three< /output_three>
        </namesp2:TestRespo nse>
        </soap:Body>
        </soap:Envelope>

        which seems more correct to me, and indeed works with both .NET and
        Axis, all parameters are received correctly. Obviously I'm happy that
        this works, however I'm confused as to why. I would have thought
        setting a namespace of nothing wouldn't make sense, and certainly
        wouldn't a namespace to the envelope. I assume that the urn:Test
        namespace is being picked up from the request, as in this case I've
        not passed it in anywhere on the server side.

        One possibility I haven't really investigated is that the WSDL i've
        written could be wrong, but I can't see how I can modify it without
        breaking it. Attached is the WSDL and the CGI script i'm testing
        against. Can someone with a bit more knowledge of varying SOAP
        implementations shed any light on what's happening here?

        Thanks,

        Andrew Bayliss

        <soap_test.pl>
        <Test.wsdl>

      • Andrew Bayliss
        Kevin, I m not sure what this achieves, everything seems to work fine regardless of what the soap namespace prefix in the WSDL is. Andrew
        Message 3 of 5 , Jun 13, 2006
        • 0 Attachment
          Kevin,

          I'm not sure what this achieves, everything seems to work fine
          regardless of what the soap namespace prefix in the WSDL is.

          Andrew


          On 6/12/06, Kevin Stone <kevin.stone@...> wrote:
          >
          >
          >
          > I notice a
          >
          > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
          >
          >
          > If you take your wsdl and do
          >
          >
          > cat my.wsdl | sed -e s/soap:/other:/g | sed -e s/xmlns:soap/xmlns:other/g > new.wsdl
          >
          >
          > (to change all of the soap: namespace prefix to something different...)
          >
          >
          > You can then use
          >
          >
          > #!/usr/bin/perl
          >
          >
          > use SOAP::Lite;
          > use Data::Dumper;
          >
          >
          > my $client = SOAP::Lite->service("new.wsdl");
          > my $ret = $client->myfunction( 1, "someotherparameter" );
          > print Dumper $ret;
          >
          >
          > and avoid a lot of hassle...
        • Kevin Stone
          Sorry- I misread your email and thought you were using perl as a client, not a server. On Jun 13, 2006, at 6:26 AM, Andrew Bayliss wrote: Kevin, I m not sure
          Message 4 of 5 , Jun 13, 2006
          • 0 Attachment
            Sorry- I misread your email and thought you were using perl as a client, not a server.

            On Jun 13, 2006, at 6:26 AM, Andrew Bayliss wrote:

            Kevin,

            I'm not sure what this achieves, everything seems to work fine
            regardless of what the soap namespace prefix in the WSDL is.

            Andrew

            On 6/12/06, Kevin Stone <kevin.stone@mac.com> wrote:
            >
            >
            >
            > I notice a
            >
            > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
            >
            >
            > If you take your wsdl and do
            >
            >
            > cat my.wsdl | sed -e s/soap:/other:/g | sed -e s/xmlns:soap/xmlns:other/g > new.wsdl
            >
            >
            > (to change all of the soap: namespace prefix to something different...)
            >
            >
            > You can then use
            >
            >
            > #!/usr/bin/perl
            >
            >
            > use SOAP::Lite;
            > use Data::Dumper;
            >
            >
            > my $client = SOAP::Lite->service("new.wsdl");
            > my $ret = $client->myfunction( 1, "someotherparameter" );
            > print Dumper $ret;
            >
            >
            > and avoid a lot of hassle...


          Your message has been successfully submitted and would be delivered to recipients shortly.