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

Problem with Array of Struct (SoapLite Server & MSSoap Client)

Expand Messages
  • Заостровцев Николай
    Hi, I want to write a server which returns a array of structures with the information on domains. But I had problems at work with the MS Soap Toolkit client. I
    Message 1 of 3 , Sep 20, 2001
    • 0 Attachment
      Problem with Array of Struct (SoapLite Server & MSSoap Client)

      Hi,
      I want to write a server which returns a array of structures with the information on domains.
      But I had problems at work with the MS Soap Toolkit client.

      I receive the message on a "Automation Error" but if to replace
      a line  "wsdl:arrayType='typens:DomainInfo[]'" with a line "wsdl:arrayType='SOAPStruct'"  in ArrayOfDomain declaration
      all works perfectly. But then the WSDL file not correct.

      I think, I should use SOAP:: DATA for formatting result, but I not so understand, how.

      Thank you in advance!
      With kind regards,
        Nick
       

      Look a code below:

      Sample server code:
      #!/usr/bin/perl -w
      use SOAP::Transport::HTTP;
      SOAP::Transport::HTTP::CGI  
        -> dispatch_to('DOMAINS')    
        -> handle;

      package DOMAINS;
      sub Test{
       $rec = {
        NAME => "domain_name",
        STATUS => "delegated"
        };
       $rec1 = {
        NAME => "domain_name1",
        STATUS => "delayed"
        };
       push @a, $rec ;
       push @a, $rec1 ;
       return \@a;
      }


      Server result:

        <?xml version="1.0" encoding="UTF-8" ?>
       <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">

       <SOAP-ENV:Body>
       <namesp1:TestResponse xmlns:namesp1="http://localhost/DOMAINS">
       <SOAP-ENC:Array SOAP-ENC:arrayType="SOAPStruct[2]" xsi:type="SOAP-ENC:Array">
       <s-gensym5 xsi:type="SOAP-ENC:SOAPStruct">
        <STATUS xsi:type="xsd:string">delegated</STATUS>
        <NAME xsi:type="xsd:string">domain_name</NAME>
        </s-gensym5>
       <s-gensym5 xsi:type="SOAP-ENC:SOAPStruct">
        <STATUS xsi:type="xsd:string">delayed</STATUS>
        <NAME xsi:type="xsd:string">domain_name1</NAME>
        </s-gensym5>
        </SOAP-ENC:Array>
        </namesp1:TestResponse>
        </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
       

      WSDL file:
      <?xml version = "1.0"?>
      <definitions name="DOMAINS"
           targetNamespace="http://localhost/domains/domains.wsdl"
        xmlns:typens='http://tempuri.org/type'
        xmlns:tns="http://localhost/domains/domains.wsdl"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
           xmlns="http://schemas.xmlsoap.org/wsdl/">
         <types>
        <schema targetNamespace='http://tempuri.org/type'
          xmlns='http://www.w3.org/2001/XMLSchema'
          xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
          xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
          elementFormDefault='qualified'>

            <complexType name='DomainInfo'>
              <all>
                <element name='NAME' type='string'/>
                <element name='STATUS' type='string'/>
              </all>
            </complexType>

            <complexType name ='ArrayOfDomain'>
              <complexContent>
                <restriction base='SOAP-ENC:Array'>
                  <attribute ref='SOAP-ENC:arrayType' wsdl:arrayType='typens:DomainInfo[]'/>
                </restriction>
              </complexContent>
            </complexType>

        </schema>
         </types>
       <message name="TestRequest">
        <part name="id" type="xsd:string" />
          </message>
          <message name="TestResponse">
           <part name="result" type="typens:ArrayOfDomain"/>
          </message>
          <portType name="DOMAINSPortType">
           <operation name="Test">
            <input message="tns:TestRequest" name="Test"/>
            <output message="tns:TestResponse"  name="TestResponse" />
           </operation>
          </portType>
         <binding name="DOMAINSServiceBinding" type="tns:DOMAINSPortType">
          <soap:binding style="rpc"  transport="http://schemas.xmlsoap.org/soap/http" />
          <operation name="Test">
         <soap:operation soapAction="http://localhost/DOMAINS#Test" />
           <input>
            <soap:body use="encoded" namespace="http://localhost/DOMAINS"
             encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
           </input>
           <output>
            <soap:body use="encoded" namespace="http://localhost/DOMAINS"
             encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
           </output>
          </operation>
         </binding>
         <service name="DOMAINSService">
          <documentation>Domains Service</documentation>
          <port name="DOMAINSPort" binding="tns:DOMAINSServiceBinding">
           <soap:address location="http://localhost:8080/domains/server.pl" />
          </port>
        </service>
      </definitions>

    • Paul Kulchenko
      Hi, îÉËÏÌÁÊ! ... You may use something like this: return [map {SOAP::Data- type(DomainInfo = $_)} $rec, $rec1]; instead of ... If you need to bind type
      Message 2 of 3 , Sep 20, 2001
      • 0 Attachment
        Hi, �������!

        > I think, I should use SOAP:: DATA for formatting result, but I not
        > so understand, how.
        You may use something like this:

        return [map {SOAP::Data->type(DomainInfo => $_)} $rec, $rec1];

        instead of

        > push @a, $rec ;
        > push @a, $rec1 ;
        > return \@a;

        If you need to bind type DomainInfo to specific namespace
        ('http://tempuri.org/type' in this example), you need to use maptype:

        my $server = SOAP::Transport::HTTP::CGI
        -> dispatch_to('DOMAINS');
        $server->serializer->maptype->{DomainInfo}
        = 'http://tempuri.org/type';
        $server->handle;

        several mapping can be specified using this:

        $server->serializer->maptype({type1 => 'ns1', type2 => 'ns2'});

        Hope it helps.

        Best wishes, Paul.

        --- ����������� ������� <nick@...> wrote:
        > Hi,
        > I want to write a server which returns a array of structures with
        > the
        > information on domains.
        > But I had problems at work with the MS Soap Toolkit client.
        >
        > I receive the message on a "Automation Error" but if to replace
        > a line "wsdl:arrayType='typens:DomainInfo[]'" with a line
        > "wsdl:arrayType='SOAPStruct'" in ArrayOfDomain declaration
        > all works perfectly. But then the WSDL file not correct.
        >
        > I think, I should use SOAP:: DATA for formatting result, but I not
        > so
        > understand, how.
        >
        > Thank you in advance!
        > With kind regards,
        > Nick
        >
        >
        > Look a code below:
        >
        > Sample server code:
        > #!/usr/bin/perl -w
        > use SOAP::Transport::HTTP;
        > SOAP::Transport::HTTP::CGI
        > -> dispatch_to('DOMAINS')
        > -> handle;
        >
        > package DOMAINS;
        > sub Test{
        > $rec = {
        > NAME => "domain_name",
        > STATUS => "delegated"
        > };
        > $rec1 = {
        > NAME => "domain_name1",
        > STATUS => "delayed"
        > };
        > push @a, $rec ;
        > push @a, $rec1 ;
        > return \@a;
        > }
        >
        >
        > Server result:
        >
        > <?xml version="1.0" encoding="UTF-8" ?>
        > <SOAP-ENV:Envelope
        > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        > <SOAP-ENV:Body>
        > <namesp1:TestResponse xmlns:namesp1="http://localhost/DOMAINS">
        > <SOAP-ENC:Array SOAP-ENC:arrayType="SOAPStruct[2]"
        > xsi:type="SOAP-ENC:Array">
        > <s-gensym5 xsi:type="SOAP-ENC:SOAPStruct">
        > <STATUS xsi:type="xsd:string">delegated</STATUS>
        > <NAME xsi:type="xsd:string">domain_name</NAME>
        > </s-gensym5>
        > <s-gensym5 xsi:type="SOAP-ENC:SOAPStruct">
        > <STATUS xsi:type="xsd:string">delayed</STATUS>
        > <NAME xsi:type="xsd:string">domain_name1</NAME>
        > </s-gensym5>
        > </SOAP-ENC:Array>
        > </namesp1:TestResponse>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        >
        > WSDL file:
        > <?xml version = "1.0"?>
        > <definitions name="DOMAINS"
        > targetNamespace="http://localhost/domains/domains.wsdl"
        > xmlns:typens='http://tempuri.org/type'
        > xmlns:tns="http://localhost/domains/domains.wsdl"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns="http://schemas.xmlsoap.org/wsdl/">
        > <types>
        > <schema targetNamespace='http://tempuri.org/type'
        > xmlns='http://www.w3.org/2001/XMLSchema'
        > xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
        > xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
        > elementFormDefault='qualified'>
        >
        > <complexType name='DomainInfo'>
        > <all>
        > <element name='NAME' type='string'/>
        > <element name='STATUS' type='string'/>
        > </all>
        > </complexType>
        >
        > <complexType name ='ArrayOfDomain'>
        > <complexContent>
        > <restriction base='SOAP-ENC:Array'>
        > <attribute ref='SOAP-ENC:arrayType'
        > wsdl:arrayType='typens:DomainInfo[]'/>
        > </restriction>
        > </complexContent>
        > </complexType>
        >
        > </schema>
        > </types>
        > <message name="TestRequest">
        > <part name="id" type="xsd:string" />
        > </message>
        > <message name="TestResponse">
        > <part name="result" type="typens:ArrayOfDomain"/>
        > </message>
        > <portType name="DOMAINSPortType">
        > <operation name="Test">
        > <input message="tns:TestRequest" name="Test"/>
        > <output message="tns:TestResponse" name="TestResponse" />
        > </operation>
        > </portType>
        > <binding name="DOMAINSServiceBinding"
        > type="tns:DOMAINSPortType">
        > <soap:binding style="rpc"
        > transport="http://schemas.xmlsoap.org/soap/http" />
        > <operation name="Test">
        > <soap:operation soapAction="http://localhost/DOMAINS#Test" />
        > <input>
        > <soap:body use="encoded" namespace="http://localhost/DOMAINS"
        > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
        > </input>
        > <output>
        > <soap:body use="encoded" namespace="http://localhost/DOMAINS"
        > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
        > </output>
        > </operation>
        > </binding>
        > <service name="DOMAINSService">
        > <documentation>Domains Service</documentation>
        > <port name="DOMAINSPort" binding="tns:DOMAINSServiceBinding">
        > <soap:address
        > location="http://localhost:8080/domains/server.pl" />
        > </port>
        > </service>
        > </definitions>
        >


        __________________________________________________
        Terrorist Attacks on U.S. - How can you help?
        Donate cash, emergency relief information
        http://dailynews.yahoo.com/fc/US/Emergency_Information/
      • nick@metric.ru
        It has helped. Thank you! With kind regards, Nick
        Message 3 of 3 , Sep 25, 2001
        • 0 Attachment
          It has helped.
          Thank you!
          With kind regards,
          Nick

          --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
          > Hi, îÉËÏÌÁÊ!
          >
          > > I think, I should use SOAP:: DATA for formatting result, but I not
          > > so understand, how.
          > You may use something like this:
          >
          > return [map {SOAP::Data->type(DomainInfo => $_)} $rec, $rec1];
          >
          > instead of
          >
          > > push @a, $rec ;
          > > push @a, $rec1 ;
          > > return \@a;
          >
          > If you need to bind type DomainInfo to specific namespace
          > ('http://tempuri.org/type' in this example), you need to use
          maptype:
          >
          > my $server = SOAP::Transport::HTTP::CGI
          > -> dispatch_to('DOMAINS');
          > $server->serializer->maptype->{DomainInfo}
          > = 'http://tempuri.org/type';
          > $server->handle;
          >
          > several mapping can be specified using this:
          >
          > $server->serializer->maptype({type1 => 'ns1', type2 => 'ns2'});
          >
          > Hope it helps.
          >
          > Best wishes, Paul.
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.