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

Arrays and Interoperate with .NET problems

Expand Messages
  • parcelstring
    Is there a document or thread anywhere which can help me return an array of complex types to a .NET client. I think i am almost there, but not quite. I have 2
    Message 1 of 1 , Nov 14, 2005
    • 0 Attachment
      Is there a document or thread anywhere which can help me return an
      array of complex types to a .NET client.

      I think i am almost there, but not quite. I have 2 servers which both
      return the same object, one is written in .NET the other in Perl. Here
      is the response envelope from them both. .NET seems to think that the
      response from the perl server is a null array but its obviously nor.

      The server code is at the very bottom.

      ---Perl Server Returns---
      <?xml version="1.0" encoding="utf-16"?>
      <SOAP-ENV:Envelope
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:namesp3="http://namespaces.soaplite.com/perl"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <namesp1:FindCustomersResponse xmlns:namesp1="urn:SearchService">
      <namesp2:Customer xsi:type="namesp3:Customer"
      xmlns:namesp2="SearchService">
      <creditCycleLimit
      xsi:type="xsd:string">creditCycleLimit1</creditCycleLimit>
      <creditCheckId
      xsi:type="xsd:string">creditCheckId1</creditCheckId>
      <status xsi:type="xsd:string">status1</status>
      <vspId xsi:type="xsd:string">vspId1</vspId>
      <salesPersonId
      xsi:type="xsd:string">salesPersonId1</salesPersonId>
      <billCycleId xsi:type="xsd:string">billCycleId1</billCycleId>
      <companyName xsi:type="xsd:string">companyName1</companyName>
      <languageId xsi:type="xsd:string">languageId1</languageId>
      <customerId xsi:type="xsd:string">customerId1</customerId>
      <currencyId xsi:type="xsd:string">currencyId1</currencyId>
      <costCentreId xsi:type="xsd:string">costCentreId1</costCentreId>
      <primaryContactId
      xsi:type="xsd:string">promaryContactId1</primaryContactId>
      </namesp2:Customer>
      <namesp2:Customer xsi:type="namesp3:Customer"
      xmlns:namesp2="SearchService">
      <creditCycleLimit
      xsi:type="xsd:string">creditCycleLimit2</creditCycleLimit>
      <creditCheckId
      xsi:type="xsd:string">creditCheckId2</creditCheckId>
      <status xsi:type="xsd:string">status2</status>
      <vspId xsi:type="xsd:string">vspId2</vspId>
      <salesPersonId
      xsi:type="xsd:string">salesPersonId2</salesPersonId>
      <billCycleId xsi:type="xsd:string">billCycleId2</billCycleId>
      <companyName xsi:type="xsd:string">companyName2</companyName>
      <languageId xsi:type="xsd:string">languageId2</languageId>
      <customerId xsi:type="xsd:string">customerId2</customerId>
      <currencyId xsi:type="xsd:string">currencyId2</currencyId>
      <costCentreId xsi:type="xsd:string">costCentreId2</costCentreId>
      <primaryContactId
      xsi:type="xsd:string">promaryContactId2</primaryContactId>
      </namesp2:Customer>
      </namesp1:FindCustomersResponse>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      ---.NET server returns---
      <?xml version="1.0" encoding="utf-16"?>
      <soap:Envelope
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <FindCustomersResponse xmlns="http://tempuri.org/">
      <FindCustomersResult>
      <Customer>
      <customerId>tring</customerId>
      <vspId>string</vspId>
      <primaryCostactId>string</primaryCostactId>
      <companyName>xsd:string</companyName>
      <billCycleId>xsd:string</billCycleId>
      <creditCheckId>xsd:string</creditCheckId>
      <creditCycleLimit>xsd:string</creditCycleLimit>
      <languageId>xsd:string</languageId>
      <currencyId>xsd:string</currencyId>
      <salesPersonId>xsd:string</salesPersonId>
      <status>xsd:string</status>
      <costCentreId>xsd:string</costCentreId>
      </Customer>
      <Customer>
      <customerId>tring</customerId>
      <vspId>string</vspId>
      <primaryCostactId>string</primaryCostactId>
      <companyName>xsd:string</companyName>
      <billCycleId>xsd:string</billCycleId>
      <creditCheckId>xsd:string</creditCheckId>
      <creditCycleLimit>xsd:string</creditCycleLimit>
      <languageId>xsd:string</languageId>
      <currencyId>xsd:string</currencyId>
      <salesPersonId>xsd:string</salesPersonId>
      <status>xsd:string</status>
      <costCentreId>xsd:string</costCentreId>
      </Customer>
      </FindCustomersResult>
      </FindCustomersResponse>
      </soap:Body>
      </soap:Envelope>

      ----Server Code----
      #!/usr/bin/perl

      use SOAP::Lite;
      use SOAP::Transport::HTTP ;
      use DBI;
      use Admin::SearchModule;

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('SearchService')
      -> on_action(sub{sprintf '%s/%s', @_ })
      -> serializer(My::Serializer->new)
      -> handle;

      package SearchService;

      sub FindCustomers{
      return SOAP::Data
      -> name('Customer')
      -> uri('SearchService')
      -> value(Admin::SearchModule::FindCustomers1());
      }
      1;

      BEGIN {
      package My::Serializer;
      use vars qw(@ISA $URI);
      @ISA = 'SOAP::Serializer';

      sub envelope {
      my $self = shift;
      $self->SUPER::envelope(@_);
      }
      }


      ---Admin::SearchService package---
      package Admin::SearchModule;

      sub FindCustomers1{
      my $type = shift;
      if (ref($self)){
      $self=ref($self);
      }
      my %self = (customerId=>"customerId1",
      vspId=>"vspId1",
      primaryContactId=>"promaryContactId1",
      companyName=>"companyName1",
      billCycleId=>"billCycleId1",
      creditCheckId=>"creditCheckId1",
      creditCycleLimit=>"creditCycleLimit1",
      languageId=>"languageId1",
      currencyId=>"currencyId1",
      salesPersonId=>"salesPersonId1",
      status=>"status1",
      costCentreId=>"costCentreId1");
      my %self2 = (customerId=>"customerId2",
      vspId=>"vspId2",
      primaryContactId=>"promaryContactId2",
      companyName=>"companyName2",
      billCycleId=>"billCycleId2",
      creditCheckId=>"creditCheckId2",
      creditCycleLimit=>"creditCycleLimit2",
      languageId=>"languageId2",
      currencyId=>"currencyId2",
      salesPersonId=>"salesPersonId2",
      status=>"status2",
      costCentreId=>"costCentreId2");

      bless(\%self,'Customer');
      bless(\%self2,'Customer');

      @myArray = (\%self,\%self2);
      return @myArray;

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