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

SOAPLite Server / DotNet Client - ArrayOfString Problem (LONG)

Expand Messages
  • Mark Edwards
    Folks, I am trying to set up a .Net client to access a SOAPLite server. The server needs to return an array of string values. I have been successful at
    Message 1 of 1 , Aug 17, 2005
    View Source
    • 0 Attachment
      Folks,

      I am trying to set up a .Net client to access a SOAPLite server.
      The server needs to return an array of string values. I have been
      successful at returning a single string ("Hello World"), but not an
      array of strings. I have scoured the web for hints at what I am doing
      wrong, but so far I have hit on nothing. If anybody could point me in
      the right direction, I'd appreciate it. Here's the details:

      Server name: lancelot (RedHat ES3.0 - Apache 2.0)
      SOAPLite Version: 0.65-Beta6 (latest)
      .Net Framework: 1.1 SP1
      Development Environment: Visual Studio 2003

      The following is my test program. It returns the names of the
      Simpsons. Obviously, this is NOT what I am actually trying to do, but
      it does illustrate my problem.


      **************** SOAPLite Server (ArrayTest.cgi) *******************

      #!/usr/bin/perl -w

      use SOAP::Lite +trace=>all;
      use SOAP::Transport::HTTP;

      my $uri = "http://........../ArrayTest";

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('ArrayTest')
      -> handle;

      package ArrayTest;
      BEGIN {
      sub GetArray {
      my ($retval, @Family);

      @Family = ("Homer","Marge","Bart","Lisa","Maggie");

      $retval=SOAP::Data
      ->name('GetArrayResult' => \SOAP::Data->value(
      SOAP::Data->name("fName" => @Family )
      ->type("string")))
      ->uri("http://........../ArrayTest");

      return $retval;
      }
      }



      ***************** WSDL (ArrayTest.wsdl) ********************

      <?xml version="1.0" encoding="utf-8"?>
      <wsdl:definitions
      xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:s="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:tns="http://........../ArrayTest"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      targetNamespace="http://........../ArrayTest">
      <wsdl:types>
      <s:schema elementFormDefault="qualified"
      targetNamespace="http://........../ArrayTest">
      <s:element name="GetArray">
      <s:complexType />
      </s:element>
      <s:element name="GetArrayResponse">
      <s:complexType>
      <s:sequence>
      <s:element minOccurs="0" maxOccurs="1"
      name="GetArrayResult" type="tns:ArrayOfString" />
      </s:sequence>
      </s:complexType>
      </s:element>
      <s:complexType name="ArrayOfString">
      <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="string"
      nillable="true" type="s:string" />
      </s:sequence>
      </s:complexType>
      </s:schema>
      </wsdl:types>
      <wsdl:message name="GetArraySoapIn">
      <wsdl:part name="parameters" element="tns:GetArray" />
      </wsdl:message>
      <wsdl:message name="GetArraySoapOut">
      <wsdl:part name="parameters" element="tns:GetArrayResponse" />
      </wsdl:message>
      <wsdl:portType name="ArrayTestSoap">
      <wsdl:operation name="GetArray">
      <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">This
      method returns the list of Simpsons.</documentation>
      <wsdl:input message="tns:GetArraySoapIn" />
      <wsdl:output message="tns:GetArraySoapOut" />
      </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="ArrayTestSoap" type="tns:ArrayTestSoap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
      style="document" />
      <wsdl:operation name="GetArray">
      <soap:operation
      soapAction="http://........../ArrayTest/GetArray" style="document" />
      <wsdl:input>
      <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
      <soap:body use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="ArrayTest">
      <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Service to
      list Simpson Family names</documentation>
      <wsdl:port name="ArrayTestSoap" binding="tns:ArrayTestSoap">
      <soap:address location="http://lancelot/cgi-bin/ArrayTest.cgi" />
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>



      ***************** SOAPLite Client (works!) ********************

      #!/usr/bin/perl -w

      use SOAP::Lite;# +trace=>'debug';
      use LiteralSerializer;

      my $uri = "http://........../ArrayTest";

      my $service = SOAP::Lite
      ->proxy('http://lancelot/cgi-bin/ArrayTest.cgi')
      ->uri($uri)
      ->readable(1);

      my $som = $service->call('GetArray');
      my @names = $som->valueof('//GetArrayResult//fName');
      while (@names) {
      my $fname = shift(@names);
      print $fname,"\n";
      }



      ***************** .Net Client (doesn't work!) ********************

      This is a bit tricky - the client is web application with 2 controls,
      a button and a table. Pressing the button results in a call to the
      ArrayTest webservice, which has been added to the project under the
      name "lancelot". Ignore the table control for now. The "click" event
      handler is shown below:

      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
      System.EventArgs) Handles Button1.Click
      Dim ws As New lancelot.ArrayTest
      Dim result As String()
      Dim a As TableRow
      Dim b As TableCell
      Dim i As Integer

      Try
      result = ws.GetArray()
      For i = 0 To result.GetUpperBound(0)
      b = New TableCell
      b.Text = result(i)
      a = New TableRow
      a.Cells.Add(b)
      Table1.Rows.Add(a)
      Next
      Catch ex As Exception
      Throw
      End Try

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