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

      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";

      -> dispatch_to('ArrayTest')
      -> handle;

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

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

      ->name('GetArrayResult' => \SOAP::Data->value(
      SOAP::Data->name("fName" => @Family )

      return $retval;

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

      <?xml version="1.0" encoding="utf-8"?>
      <s:schema elementFormDefault="qualified"
      <s:element name="GetArray">
      <s:complexType />
      <s:element name="GetArrayResponse">
      <s:element minOccurs="0" maxOccurs="1"
      name="GetArrayResult" type="tns:ArrayOfString" />
      <s:complexType name="ArrayOfString">
      <s:element minOccurs="0" maxOccurs="unbounded" name="string"
      nillable="true" type="s:string" />
      <wsdl:message name="GetArraySoapIn">
      <wsdl:part name="parameters" element="tns:GetArray" />
      <wsdl:message name="GetArraySoapOut">
      <wsdl:part name="parameters" element="tns:GetArrayResponse" />
      <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:binding name="ArrayTestSoap" type="tns:ArrayTestSoap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
      style="document" />
      <wsdl:operation name="GetArray">
      soapAction="http://........../ArrayTest/GetArray" style="document" />
      <soap:body use="literal" />
      <soap:body use="literal" />
      <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" />

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

      #!/usr/bin/perl -w

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

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

      my $service = SOAP::Lite

      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

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

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