Apache Axis - Soap

From: Atum Sargas (atum_at_gmx.net)
Date: 11/14/03


Date: Fri, 14 Nov 2003 13:24:06 +0100

Hi all,

I have read some tutorial to Soap, but I dont get the point.
My "simple" Problem is to turn the XML Soap Document into an Array

This is the starting Point of my Problems:

<-- snip ---
<?xml version="1.0" encoding="ISO-8859-1"?>

<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
   xmlns:si="http://soapinterop.org/xsd">
<SOAP-ENV:Body>
<dslcheckResponse>
<soapVal>

<INFO>
     <RETURN_CODE xsi:type="xsd:int">104</RETURN_CODE>
     <RETURN_STRING xsi:type="xsd:string">found</RETURN_STRING>
</INFO>

<RESULT xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="SOAP-ENC:Array[34]">
     <item>
         <STATUS>
             <STATUS_CODE xsi:type="xsd:int">103</STATUS_CODE>
             <STATUS_STRING
xsi:type="xsd:string">blacklisted</STATUS_STRING>
         </STATUS>

         <ADDRESS>
             <AREACODE xsi:type="xsd:string">089</AREACODE>
             <STREET xsi:type="xsd:string">Kirchenweg </STREET>
             <ZIP xsi:type="xsd:string">0</ZIP>
         </ADDRESS>
         <BLACKLIST>
             <AREACODE xsi:type="xsd:string">089</AREACODE>
             <STREET xsi:type="xsd:string">Kirchenweg </STREET>
             <ZIP xsi:type="xsd:string">0</ZIP>
         </BLACKLIST>
         <LAP>
             <AREACODE xsi:type="xsd:string">089</AREACODE>
             <ASB_NAME xsi:type="xsd:string">Unterföhring</ASB_NAME>
             <ASB_NR xsi:type="xsd:string">950</ASB_NR>
             <CITY xsi:type="xsd:string">Unterföhring</CITY>
             <OPAL xsi:type="xsd:string">0</OPAL>
             <REGION xsi:type="xsd:string"></REGION>
             <STREET xsi:type="xsd:string">Münchner Str. 66</STREET>
             <ZIP xsi:type="xsd:string">85774</ZIP>
         </LAP>
         <PROVIDER>
             <soapVal>
                 <LAP_AVAILABILITY xsi:type="xsd:nil"/>
                 <LAP_DATE_AVAILABLE xsi:type="xsd:nil"/>
                 <LAP_DESCRIPTION xsi:type="xsd:nil"/>
                 <LAP_MIN xsi:type="xsd:nil"/>
                 <LAP_MAX xsi:type="xsd:nil"/>
                 <NAME xsi:type="xsd:nil"/>
                 <PRIORITY xsi:type="xsd:nil"/>
             </soapVal>
         </PROVIDER>
     </item>

[... more of them ...]

</RESULT>

</soapVal>
</dslcheckResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

---------------snap-----------------

I dont have any problems to get the xml Data as a Document.

But what I dont understand is, how Do I read the Array into Java.
Obviously this is an String Array. But the first step to turn the
"RESULT" into an ArrayList is a problem.

My Question is how do I have to call the server to get an Array from

<RESULT xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="SOAP-ENC:Array[34]">

Or maybe its easier if somebody can explain to me how do I turn

<INFO>
     <RETURN_CODE xsi:type="xsd:int">104</RETURN_CODE>
     <RETURN_STRING xsi:type="xsd:string">found</RETURN_STRING>
</INFO>

from the response into "int" and "String", i need just an example, which
would push me forwards.

This is what I have done till now. What I can do is to transform the
document with xslt, but this is a SOAP, and I want to take this way.
I know, this has something to do with the ReturnType of the Document,
but what I have to set to gain it?

I'am using APACHE AXIS.

---- snip ----

   public Document getDocument(String areacode, String street, String
house){

     Document doc = null;

     //PbLogger.log( " ************** DSLCHECK *************** " +
areacode + " " + street + " " + house );

     try {

       Object info = null;
       Object result = null;

       Service service = new Service();
       Call call = (Call) service.createCall();

       call.setTargetEndpointAddress( new java.net.URL( this.endpoint ) );
       //call.setOperationName(new QName("http:\\dslcheck", "dslcheck"));
       call.setOperationName(new QName("dslcheck"));
       call.setOperationStyle("rpc");
       call.setUsername(this.user);
       call.setPassword(this.password);

       call.addParameter("areacode", XMLType.XSD_STRING, ParameterMode.IN);
       call.addParameter("street", XMLType.XSD_STRING, ParameterMode.IN);
       call.addParameter("house", XMLType.XSD_STRING, ParameterMode.IN);
       call.setReturnType( org.apache.axis.encoding.XMLType.XSD_ANYTYPE );

       Node node = ( Node ) call.invoke( new Object[] { areacode,
street, house } );

       System.out.println( "Encoding Style" + call.getEncodingStyle() );

       Node parentNode = node.getParentNode();
       DomPrinter domPrinter = new DomPrinter();
          domPrinter.printDOMTree( parentNode );

       System.out.println("\n------------------------------\n");

       Message message = call.getResponseMessage();
       SOAPEnvelope soapEnvelope = message.getSOAPEnvelope();
          Vector vc = soapEnvelope.getBodyElements();
        
          for( int i = 0; i < vc.size() ; i++){
                  SOAPBodyElement sbe = (SOAPBodyElement) vc.elementAt(i);
                  doc = sbe.getAsDocument();
                
                domPrinter.printDOMTree( doc );
          }

     } catch (Exception e) {
         System.err.println(e.toString());
         //PbLogger.logErr( "DslCheck:getDocument", e );
     }

     return doc;
   }

---- snap ----

Thx.
atum



Relevant Pages

  • Problem when switching from SoapClient to WebServicesClientProtocol
    ... I have a working C# class library that acts as a soap client. ... over the formatting of the soap body: ... It all boils down to the "this.invoke" method requiring an object array ... //populate the test widgets array ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: PHP-like Array/Hash creation in Ruby
    ... but the autogrowing is limited to the last dimension. ... i dont have constant size of elements that could be added in just one ... want to store them in a 3 dimensional array. ... I do like Ruby very much from the first looks ...
    (comp.lang.ruby)
  • Re: How to do: Web Services returning a class that inherits arrayl
    ... Array types can be defined in the soap schema. ... I have a class called CartLine and I try to return this class in a Web ... The proxy reference doesn't contain any information even though I use the ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Question about cgi forms (slightly OT)
    ... > If you normalize the CGI input to a sane value (IE, make string zero ... > the order they are placed into the array then you can use array ... dont think I was clear enough ... through the fields, edit etc, but if I do a control F for instance, the ...
    (perl.beginners)
  • Re: look into control array for colission detection
    ... Im sort of new to vb6. ... > array to see if the fire-ball left the screen the unload it. ... > Still good to me that I dont leak mem. ...
    (microsoft.public.vb.controls)