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

RE: [soaplite] Soap::Lite to .net web service , complex type

Expand Messages
  • gary_grubb@agilent.com
    Marcello, take a look at this note I received from a fellow SOAP::LIte user: It not only deals with passing arrays of strings, but also how to deal with
    Message 1 of 2 , Oct 21, 2004
    • 0 Attachment

      Marcello,

       

      take a look at this note I received from a fellow SOAP::LIte user: It not only deals with passing arrays of strings, but also how to deal with SOAP::Lite implicit conversion of a string that is in the form of "123" into an array of ints.

      Gary

      I've attached perl example to pass an array and force the type to a

      string. The soap send string is pasted below:

      ( I also answered your message on the SOAP::Lite user's group.)

      <?xml version="1.0" encoding="UTF-8"?>

      <SOAP-ENV:Envelope

      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"

      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"

      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

      xmlns:xsd="http://www.w3.org/1999/XMLSchema"

      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

      <SOAP-ENV:Body>

      <namesp1:soapTest xmlns:namesp1="SoapTest">

      <arrayTest xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[3]">

      <item xsi:type="xsd:string">1</item>

      <item xsi:type="xsd:string">2</item>

      <item xsi:type="xsd:string">3</item>

      </arrayTest>

      </namesp1:soapTest>

      </SOAP-ENV:Body>

      </SOAP-ENV:Envelope>

      The magic is the line:

      ->value( [ map { SOAP::Data->value( $_ )->type( 'string' ) } @buffer ] );

      This line takes each element of @buffer, and transforms it into a

      SOAP::Data object with a type of string. then passes the reference to

      the new array to the SOAP::Data constuctor to creat the parent object.

      -Scott

      -----Original Message-----
      From: marcello_tiso [mailto:marcello_tiso@...]
      Sent: Thursday, October 21, 2004 1:22 PM
      To: soaplite@yahoogroups.com
      Subject: [soaplite] Soap::Lite to .net web service , complex type


      Hello,
      I looked through the archive and tried some of the suggestions but
      none seem to work (or perhaps I havent implemented it correctly).

      I am trying to send a method a string and then an array of strings.

      The SOAP request looks like this:
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:tns="http://tempuri.org/"
      xmlns:types="http://tempuri.org/encodedTypes"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <q1:getGenericValues xsi:type="q1:getGenericValues"
      xmlns:q1="http://www.tempuri.org">
            <message xsi:type="xsd:string">string</message>
            <parameters href="#id1" />
          </q1:getGenericValues>
          <soapenc:Array id="id1" soapenc:arrayType="xsd:string[2]">
            <Item>string</Item>
            <Item>string</Item>
          </soapenc:Array>
        </soap:Body>
      </soap:Envelope>

      my Client code looks like the following (relevant piece) :

      sub getGenericValues {
        my ($message,@values) = @_;
        my $soap = SOAP::Lite
                       -> uri($ns)
                  -> on_action( sub {return  "$ns".$_[1] ;})
                  -> proxy
      ("http://someMachine.com/WebServiceDaemon/DaemonService.asmx");
        my $method = SOAP::Data->name('getGenericValues')->attr({xmlns
      => "http://www.tempuri.org"});
      my $method = SOAP::Data->name('getGenericValues')->attr({xmlns
      => "http://www.tempuri.org"});

      @foo = ('1parm','2parm');

      SOAP::Data->name('parameters' =>\SOAP::Data->value(SOAP::Data->name
      ("Item" => @foo)->type('xsd:string'))->attr({'SOAP-ENC:arrayType'
      =>'xsd:string[2]'}))->type("SOAP-ENC:Array"));


      The error I get from the server is : Object reference not set to an
      instance of an object, which I believe is in ref to href=#id1.

      Any Suggestions on how to send a .NET webservice arrays is
      appreciated.

      Thanks in advance.

      Marcello







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