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

complexTypes to a .NET client

Expand Messages
  • perlmedian
    Okay.. I have been doing a lot of reading/research. So let me lay out my problem concisely. I can get the .NET client to connect and transfer simple data with
    Message 1 of 3 , Jun 23, 2003
    View Source
    • 0 Attachment
      Okay.. I have been doing a lot of reading/research. So let me lay out
      my problem concisely.

      I can get the .NET client to connect and transfer simple data with my
      SOAP::Lite server. When I try to implement a "simple" complexType
      the .NET client fails with this error:

      Cannot assign object of type System.String[] to an object of type
      Test.www.FileRevPair[].

      I have created a WSDL with the following types:

      <xsd:complexType name="FileRevPair">
      <xsd:sequence>
      <xsd:element name="file" type="xsd:string"/>
      <xsd:element name="revision" type="xsd:string"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="ArrayOfFileRevPairs">
      <xsd:complexContent>
      <xsd:restriction base="enc:Array">
      <xsd:attribute ref="enc:arrayType"
      wsdl:arrayType="tns:FileRevPair[]" />
      </xsd:restriction>
      </xsd:complexContent>
      </xsd:complexType>



      This is a sample of the SOAP response from my SOAP::Lite server:

      <namesp1:getFileRevisionResponse xmlns:namesp1="urn:FileInfo">
      <namesp2:Files xmlns:namesp2="urn:FileInfo" SOAP-
      ENC:arrayType="xsd:ur-type[4]" xsi:type="SOAP-ENC:Array">
      <item>
      <namesp3:file xmlns:namesp3="urn:FileInfo"
      xsi:type="xsd:string">src/Accounting.cc</namesp3:file>
      <namesp4:revision xmlns:namesp4="urn:FileInfo"
      xsi:type="xsd:string">1.17</namesp4:revision>
      </item>
      </namesp2:Files>
      </namesp1:getFileRevisionResponse>



      The following link was useful but doesn't provide much detail on the
      implementation of a .NET client with a SOAP::Lite server:
      http://msdn.microsoft.com/webservices/building/default.aspx?
      pull=/library/en-us/dnsoap/html/soapliteperl.asp


      Can anyone help me or point in the direction of packaging up the
      server response so the .NET client can understand complexTypes? I
      have not read anywhere that it is NOT possible to do this. A point in
      the right direction would be very helpful and much appreciated!

      Thanx,
      Nik
    • jpeyser
      Nik, First, the MS SOAP Toolkit comes with a User Guide that contains explanations and sample code for handling complex data types. Second, the response from
      Message 2 of 3 , Jun 23, 2003
      View Source
      • 0 Attachment
        Nik,

        First, the MS SOAP Toolkit comes with a User Guide that contains
        explanations and sample code for handling complex data types.

        Second, the response from the server contains too many namespaces.
        The response should be simpler, as such.

        <namesp1:getFileRevisionResponse xmlns:namesp1="getFileRevision">
        <item>
        <Files xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:ur-type
        [2]">
        <file xsi:type="xsd:string">src/Accounting.cc</file>
        <revision xsi:type="xsd:float">1.17</revision>
        </Files>
        </item>
        </namesp1:getFileRevisionResponse>

        The following code generates the above SOAP/XML

        my @a = (
        SOAP::Data->name('file' => "$group.file"),
        SOAP::Data->name('revision' => '7.4'),
        );

        return SOAP::Data->name($group => \SOAP::Data->value(
        SOAP::Data->name('refPath' => '/test/file'),
        SOAP::Data->name('Files' => \@a),
        ));

        Third, as found in the aforementioned user's guide, the WSDL type
        definition can be simpler.

        <types>
        <schema
        xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="getFileRevision/ns2.xsd"
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:ns2="getFileRevision/ns2.xsd"
        xmlns:ns="getFileRevision">

        <complexType name="groupsArray">
        <sequence>
        <element name="file" type="xsd:string"/>
        <element name="revision" type="xsd:string"/>
        </sequence>
        </complexType>

        <complexType name="getFileRevisionResponse">
        <all>
        <element name="Files" type="ns2:groupsArray" minOccurs="0"
        maxOccurs="0"/>
        </all>
        </complexType>

        </schema>
        </types>

        Last, not being a vb programmer, I haven't figured out how to load
        the results into an array. The best I can do is to put the results
        into a string.

        a = soapclient.getFileRevisions("file", 1)

        (Anyone?)

        Jonathan


        --- In soaplite@yahoogroups.com, "perlmedian" <perlmedian@y...> wrote:
        > Okay.. I have been doing a lot of reading/research. So let me lay
        out
        > my problem concisely.
        >
        > I can get the .NET client to connect and transfer simple data with
        my
        > SOAP::Lite server. When I try to implement a "simple" complexType
        > the .NET client fails with this error:
        >
        > Cannot assign object of type System.String[] to an object of type
        > Test.www.FileRevPair[].
        >
        > I have created a WSDL with the following types:
        >
        > <xsd:complexType name="FileRevPair">
        > <xsd:sequence>
        > <xsd:element name="file" type="xsd:string"/>
        > <xsd:element name="revision" type="xsd:string"/>
        > </xsd:sequence>
        > </xsd:complexType>
        >
        > <xsd:complexType name="ArrayOfFileRevPairs">
        > <xsd:complexContent>
        > <xsd:restriction base="enc:Array">
        > <xsd:attribute ref="enc:arrayType"
        > wsdl:arrayType="tns:FileRevPair[]" />
        > </xsd:restriction>
        > </xsd:complexContent>
        > </xsd:complexType>
        >
        >
        >
        > This is a sample of the SOAP response from my SOAP::Lite server:
        >
        > <namesp1:getFileRevisionResponse xmlns:namesp1="urn:FileInfo">
        > <namesp2:Files xmlns:namesp2="urn:FileInfo" SOAP-
        > ENC:arrayType="xsd:ur-type[4]" xsi:type="SOAP-ENC:Array">
        > <item>
        > <namesp3:file xmlns:namesp3="urn:FileInfo"
        > xsi:type="xsd:string">src/Accounting.cc</namesp3:file>
        > <namesp4:revision xmlns:namesp4="urn:FileInfo"
        > xsi:type="xsd:string">1.17</namesp4:revision>
        > </item>
        > </namesp2:Files>
        > </namesp1:getFileRevisionResponse>
        >
        >
        >
        > The following link was useful but doesn't provide much detail on
        the
        > implementation of a .NET client with a SOAP::Lite server:
        > http://msdn.microsoft.com/webservices/building/default.aspx?
        > pull=/library/en-us/dnsoap/html/soapliteperl.asp
        >
        >
        > Can anyone help me or point in the direction of packaging up the
        > server response so the .NET client can understand complexTypes? I
        > have not read anywhere that it is NOT possible to do this. A point
        in
        > the right direction would be very helpful and much appreciated!
        >
        > Thanx,
        > Nik
      • perlmedian
        ... Thanks for the reference but it only helps me with understanding what is expected from .NET not how to implement it in SOAP::Lite. I have read through most
        Message 3 of 3 , Jun 23, 2003
        View Source
        • 0 Attachment
          See inline:

          --- In soaplite@yahoogroups.com, "jpeyser" <jpeyser@p...> wrote:
          > Nik,
          >
          > First, the MS SOAP Toolkit comes with a User Guide that contains
          > explanations and sample code for handling complex data types.

          Thanks for the reference but it only helps me with understanding what
          is expected from .NET not how to implement it in SOAP::Lite. I have
          read through most examples of SOAP::Lite but data on complexTypes is
          scarce.

          >
          > Second, the response from the server contains too many namespaces.
          > The response should be simpler, as such.

          I fixed that. You are right I went a bit crazy with the namespaces,
          but the types are required because of the interoperability issues
          with .NET all data needs the types explicitly defined, (it doesn't
          like it any other way).

          [SNIP]
          >
          > Third, as found in the aforementioned user's guide, the WSDL type
          > definition can be simpler.
          >
          > <types>
          > <schema
          > xmlns="http://www.w3.org/2001/XMLSchema"
          > targetNamespace="getFileRevision/ns2.xsd"
          > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
          > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          > xmlns:ns2="getFileRevision/ns2.xsd"
          > xmlns:ns="getFileRevision">
          >
          > <complexType name="groupsArray">
          > <sequence>
          > <element name="file" type="xsd:string"/>
          > <element name="revision" type="xsd:string"/>
          > </sequence>
          > </complexType>
          >
          > <complexType name="getFileRevisionResponse">
          > <all>
          > <element name="Files" type="ns2:groupsArray" minOccurs="0"
          > maxOccurs="0"/>
          > </all>
          > </complexType>
          >
          > </schema>
          > </types>
          >

          Thanks for the info. The WSDL works fine as is for me now. I don't
          want to change it until I get further with the server. The WSDL I
          used came straight from the 'Web Services With Perl' OReilly book. (I
          didn't know WSDL prior to that).


          > Last, not being a vb programmer, I haven't figured out how to load
          > the results into an array. The best I can do is to put the results
          > into a string.

          I am not to worried about the .NET end. The WSDL is what works and
          how I want to the server's data to be. Plus it's going into C# really
          and he has a grasp on the work.

          > [SNIP]

          Here's where I have come to, thanx to a e-mail from another member
          who sent me some of his code, I am stuck on what to put in
          the 'whatgoeshere???' part of my server return.

          Please any help is appreciated.

          Here's what I am returning from my SOAP::Lite server:
          return ('string')->uri('urn:FileInfo'),
          SOAP::Data->name('Files')->type
          ('whatgoeshere???:ArrayOfFileRevPairs' =>
          [ map SOAP::Data->type( 'whatgoeshere???:FileRevPairs' =>
          { file =>
          SOAP::Data->value($_)->type('string'),
          revision =>
          SOAP::Data->value($data{$_})->type('string'),
          }), @{$files} ]
          )->uri('urn:FileInfo');

          some of the WSDL:
          <types>
          <xsd:schema>
          <xsd:complexType name="FileRevPair">
          <xsd:sequence>
          <xsd:element name="file" type="xsd:string"/>
          <xsd:element name="revision" type="xsd:string"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:complexType name="ArrayOfFileRevPairs">
          <xsd:complexContent>
          <xsd:restriction base="enc:Array">
          <xsd:attribute ref="enc:arrayType"
          wsdl:arrayType="tns:FileRevPair[]" />
          </xsd:restriction>
          </xsd:complexContent>
          </xsd:complexType>

          </xsd:schema>
          </types>

          <message name="getFileRevisionResponse">
          <part name="Files" type="tns:ArrayOfFileRevPairs" />
          </message>

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