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

HOW TO - Access Nested SOAP Body Element

Expand Messages
  • maheshgadwal
    Problem Definition: I had to access a web service using SOAP. The request XML that is to be sent to a web service is a bit complex. Therefore, I got
    Message 1 of 1 , Feb 9, 2004
    • 0 Attachment
      Problem Definition: I had to access a web service using SOAP.
      The request XML that is to be sent to a web service is a bit complex.
      Therefore, I got inspiration of writing this article g How to
      access Nested SOAP Body Elementh.
      Solution: I had searched on the net regarding how to access Nested
      SOAP Body Element and I came across an article written by Byrne Reese
      gSOAP::Lite Client HOWTOh .
      URL: http://soapenv.org/article.pl?sid=02/02/11/1740229&mode=thread
      This article gave me some idea about how to access the nested SOAP
      element and after that doing many trial and run. I got the results as
      per my requirement. Here below I am giving the request format which,
      I need to generate and the code through which, I got the results.
      Request Format:
      <?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:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      <SOAP-ENV:Body>
      <Search xmlns="http://www.xyz.com/booksdata/">
      <Start xsi:type="xsd:int">1</Start>
      <Count xsi:type="xsd:int">10</Count>
      <QueryValue>
      <Items>
      <QueryItem>
      <Value xsi:type="xsd:string">'C++</Value>
      <Field xsi:type="xsd:string">FIELD_TITLE</Field>
      <FindOption
      xsi:type="xsd:string">FIND_STARTWITH</FindOption>
      </QueryItem>
      <QueryItem>
      <Value xsi:type="xsd:string">"4763194097"</Value>
      <Field xsi:type="xsd:string">FIELD_ISBN</Field>
      <FindOption
      xsi:type="xsd:string">FIND_EXACT</FindOption>
      </QueryItem>
      </Items>
      <Join xsi:type="xsd:string">CHAR_OR</Join>
      </QueryValue>
      </Search>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Sample Code:

      use SOAP::Lite;
      $sBookName = 'C++';
      $sIsbn = '4763194097';
      $soap = SOAP::Lite
      -> uri('http://www.xyz.com/booksdata/')
      -> encoding('Shift_JIS')
      -> on_action( sub { join '/', 'http://www. xyz.com /booksdata', $_
      [1] } )
      -> proxy('http:// xyz.com /booksdata/InfoSvcV02.asmx');
      $method = SOAP::Data->name('Search')->attr({xmlns => 'http://www
      xyz.com /booksdata/'});
      @params = ( SOAP::Data->name("Start" => 0),
      SOAP::Data->name("Count" => 10),
      SOAP::Data->name("QueryValue"=>
      \SOAP::Data->name("Items"=>
      \SOAP::Data->name("QueryItem"=>
      \SOAP::Data->value(SOAP::Data->name("Value" =>
      $sBookName)
      ->type("string"),
      SOAP::Data->name("Field" => "FIELD_TITLE"),
      SOAP::Data->name("FindOption"
      => "FIND_STARTWITH")),
      SOAP::Data->name("QueryItem"=>
      \SOAP::Data->value(SOAP::Data->name("Value" =>
      $sIsbn)
      ->type("string"),
      SOAP::Data->name("Field" => "FIELD_ISBN"),
      SOAP::Data->name("FindOption"
      => "FIND_EXACT")))),
      SOAP::Data->name("Join"=> "CHAR_OR"))));
      $result = $soap->call($method => @params);
      print "Search result: ".$result->result."\n";



      Mahesh Gadwal
      mahesh.gadwal@...
    Your message has been successfully submitted and would be delivered to recipients shortly.