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

RE: SOAP::Lite server to .NET/C# client and arrays

Expand Messages
  • Youngblood, Gregory S.
    I ve got a basic SOAP::Lite test server talking to a .NET console client written in C#. It works for very basic things (i.e. pass in a couple of arguments, get
    Message 1 of 3 , Oct 14, 2004
    • 0 Attachment

      I've got a basic SOAP::Lite test server talking to a .NET console client written in C#. It works for very basic things (i.e. pass in a couple of arguments, get a single return value).

       

      Next, I need to return an array of strings. Nothing too complicated. And, I have it working using perl and SOAP::Lite server/client, but so far not so much luck in C#.

       

      First, I tried to write a WSDL file that could be read and parsed to create the class file, but that hasn't worked. Next, I tried coding the C# functionality by hand. [I'm evaluating Omniopera for the WSDL editor - so far, I think it is OK for simple stuff, but the documentation is a bit light for complex things, and I can't get it to create WSDL containing an array that will be parsed by WSDL.exe with VS.NET 2003.]

       

      Google yields far more results for .Net server to SOAP::Lite client, but nothing substantial the other way. At least not with my search criteria.

       

      Does anyone have any links that explain how to do this? Or better yet, sample code (client and server)? Or, can someone give me a bit of help to make this work?

       

      I am fighting the urge to just join the data into a single string and then split it back out on the other end. That would be far easier for me right now, but it won't be doing it "correctly". I want to do this right.

       

      Thanks,
      Greg

    • Maurice McCabe
      Sometimes it is easier for a camel to pass through the eye of a needle than to try to do this correctly . But with the right kind of persistence you can
      Message 2 of 3 , Oct 14, 2004
      • 0 Attachment
        Message
        Sometimes it is easier for a camel to pass through the eye of a needle than to try to do this 'correctly'. But with the right kind of persistence you can squeeze the camel through almost any tight spot.
         
        Getting this to work correctly, means you have a high degree of interoperability with not only .NET but also Axis and nuSOAP and probably most other WSDL aware SOAP toolkits.
         
        Unless you already have Developer Studio .NET, the first thing I recommend is to download the WebServicesStudio for free from gotdotnet.com. This will allow you to build a test .NET client from your WSDL automatically. It also generates error messages on your WSDL. You won't have to fiddle with WSDL.exe, or C#, etc...
         
        Second, you can use .NET to build your WSDL by creating a Web Service that returns an array of string. Boom! Just like that your done fiddling with WSDL editors. (But you have to learn how to make a web service in .NET)
         
        Step 3. Since .NET uses the 'document/literal' format of SOAP messaging, and SOAP::Lite defaults to 'rpc/encoded' you have to switch-out the default SOAP::Lite Serializer and Deserializer. See message 3606 (http://groups.yahoo.com/group/soaplite/message/3606) for more details including an example of a WSDL for array of complex datatype. You can find the serializers here: http://ads.harvard.edu/~alberto/SOAP/
         
        If you get this far it means you have found a huge needle or a really tiny camel.
         
        Finally, use WSDL.exe to build your .dll and drop it into your .NET project.
         
        Good luck,
         
        Maurice
         
        -----Original Message-----
        From: Youngblood, Gregory S. [mailto:youngbloodg@...]
        Sent: Thursday, October 14, 2004 11:00 AM
        To: 'soaplite@yahoogroups.com'
        Subject: [soaplite] RE: SOAP::Lite server to .NET/C# client and arrays

        I've got a basic SOAP::Lite test server talking to a .NET console client written in C#. It works for very basic things (i.e. pass in a couple of arguments, get a single return value).

         

        Next, I need to return an array of strings. Nothing too complicated. And, I have it working using perl and SOAP::Lite server/client, but so far not so much luck in C#.

         

        First, I tried to write a WSDL file that could be read and parsed to create the class file, but that hasn't worked. Next, I tried coding the C# functionality by hand. [I'm evaluating Omniopera for the WSDL editor - so far, I think it is OK for simple stuff, but the documentation is a bit light for complex things, and I can't get it to create WSDL containing an array that will be parsed by WSDL.exe with VS.NET 2003.]

         

        Google yields far more results for .Net server to SOAP::Lite client, but nothing substantial the other way. At least not with my search criteria.

         

        Does anyone have any links that explain how to do this? Or better yet, sample code (client and server)? Or, can someone give me a bit of help to make this work?

         

        I am fighting the urge to just join the data into a single string and then split it back out on the other end. That would be far easier for me right now, but it won't be doing it "correctly". I want to do this right.

         

        Thanks,
        Greg


      • Maurice McCabe
        I meant Visual Studio .NET. It may not be necessary to use document/literal . I don t recall the specifics on what I ran into that caused me to standardize on
        Message 3 of 3 , Oct 14, 2004
        • 0 Attachment
          Message
          I meant Visual Studio .NET.
           
          It may not be necessary to use 'document/literal'. I don't recall the specifics on what I ran into that caused me to standardize on 'document/literal' but it was how I got it to work. And it has continued to work for Axis. Coldfusion MX and nuSOAP, including the use of more complex datatypes such as DataSet, etc.. So, so far I have not needed to switch back.
           
          The following is an example of using the serializers (including the actual serializers from Alberto):
           
          use SOAP::Lite;
          use SOAP::Transport::HTTP ;
          my $uri = 'myNameSpace';
          my $serializer = LiteralSerializer->new;
          my $deSerializer = LiteralDeserializer->new;
           

          $daemon = SOAP::Transport::HTTP::CGI
            -> serializer($serializer)
            -> deserializer($deSerializer)
            -> dispatch_to('./modules');
           
          $daemon->serializer->xmlschema('2001');
           
          $daemon -> handle ;
           
          BEGIN {
           
              package LiteralSerializer;
              @LiteralSerializer::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(@_);
              }
           
              package LiteralDeserializer;
              @LiteralDeserializer::ISA = 'SOAP::Deserializer';
              sub deserialize {
              my $self = shift;
           my $result = $self->SUPER::deserialize(@_);
             $result->{_message} = @_[0];
           return $result;
              }
           
          }
           
           
          -----Original Message-----
          From: Youngblood, Gregory S. [mailto:youngbloodg@...]
          Sent: Thursday, October 14, 2004 1:04 PM
          To: 'Maurice McCabe'
          Subject: RE: [soaplite] RE: SOAP::Lite server to .NET/C# client and arrays

          "Developer Studio .NET", do you mean Visual Studio .NET? If so, yes, I have VS.NET 2003 Enterprise.

           

          So far, I haven't had a problem with the RPC/Encoded stuff and .Net (for simple types). Is it really still necessary to switch to document/literal? Also, the Harvard URL for the serializers just sits and spins - nothing is displayed, no files listed to download. Is it on CPAN?

           

          Thanks,
          Greg

           

          -----Original Message-----
          From: Maurice McCabe [mailto:mmccabe@...]
          Sent: Thursday, October 14, 2004 2:21 PM
          To: 'Youngblood, Gregory S.'; soaplite@yahoogroups.com
          Subject: RE: [soaplite] RE: SOAP::Lite server to .NET/C# client and arrays

           

          Sometimes it is easier for a camel to pass through the eye of a needle than to try to do this 'correctly'. But with the right kind of persistence you can squeeze the camel through almost any tight spot.

           

          Getting this to work correctly, means you have a high degree of interoperability with not only .NET but also Axis and nuSOAP and probably most other WSDL aware SOAP toolkits.

           

          Unless you already have Developer Studio .NET, the first thing I recommend is to download the WebServicesStudio for free from gotdotnet.com. This will allow you to build a test .NET client from your WSDL automatically. It also generates error messages on your WSDL. You won't have to fiddle with WSDL.exe, or C#, etc...

           

          Second, you can use .NET to build your WSDL by creating a Web Service that returns an array of string. Boom! Just like that your done fiddling with WSDL editors. (But you have to learn how to make a web service in .NET)

           

          Step 3. Since .NET uses the 'document/literal' format of SOAP messaging, and SOAP::Lite defaults to 'rpc/encoded' you have to switch-out the default SOAP::Lite Serializer and Deserializer. See message 3606 (http://groups.yahoo.com/group/soaplite/message/3606) for more details including an example of a WSDL for array of complex datatype. You can find the serializers here: http://ads.harvard.edu/~alberto/SOAP/

           

          If you get this far it means you have found a huge needle or a really tiny camel.

           

          Finally, use WSDL.exe to build your .dll and drop it into your .NET project.

           

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