xml-soap-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kailash Aynor" <kail_l...@hotmail.com>
Subject Re: Array of objects serialization...
Date Thu, 10 Aug 2000 03:34:46 GMT
here is the modified code.I tweaked the Addressbook Sample to test this. The 
following changes have been made to the Addressbook class. Function
public String[] reverse(String[] strArray) has been added to the class. Here 
is function body.
Essentially it takes an array of string, reverse every 2 Strings and sends 
it back.

public static String[] reverse(String[] strArray)
    int len = strArray.length;
    for(int i =0; i < len; i++)
        if (i+1 < len)
            String tmp = strArray[i];
            strArray[i] = new String(strArray[i+1]);
            strArray[i+1] = new String(tmp);
    return strArray;

You need to add this "reverse" function in the deployment-descriptor.xml

and the client code to test this out is as follows. I have hardcoded  the 
router address. Change it accordingly.

import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;

public class test
  public static void main(String[] args) throws Exception
    String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
    URL url = new URL("http://localhost:8080/soap/rpcrouter/rpcrouter.jsp");
    SOAPMappingRegistry smr = new SOAPMappingRegistry();

    ArraySerializer aSer = new ArraySerializer();
     String[] data = new String[2];
     data[0] = new String("kailash");
     data[1] = new String("aynor");

    new QName(Constants.NS_URI_SOAP_ENC,
    String[].class, aSer, aSer);

    Vector params = new Vector();
    params.addElement(new Parameter("rootElement",
    String[].class, (String[]) data, Constants.NS_URI_SOAP_ENC));

    // Build the call.
    Call call = new Call();



    // Invoke the call.
    Response resp;
      resp = call.invoke(url, "");
    catch (SOAPException e)
      System.err.println("Caught SOAPException (" +
                         e.getFaultCode() + "): " +

    // Check the response.
    if (!resp.generatedFault())
      Parameter ret = resp.getReturnValue();
      String[] value = (String[])ret.getValue();

      System.out.println(value[0] + "   " + value[1]);
      Fault fault = resp.getFault();

      System.err.println("Generated fault: ");
      System.out.println ("  Fault Code   = " + fault.getFaultCode());
      System.out.println ("  Fault String = " + fault.getFaultString());


It worked quite well while testing. Probably this can be added to the 


>From: Deepak Patil <deepak_patil@CENTEGY.COM>
>Subject: Array of objects serialization...
>Date: Wed, 9 Aug 2000 13:38:26 -0700
>I am still stuck up with that arrayserializer...do anybody has a running
>example using ArraySerializer....
>I am getting an exception :
>Caught SOAPException (SOAP-ENV:Client): Unable to retrieve 'myName' 
>value: object is not
>an instance of declaring class.
>It will be highly appreciated, if anyone did it please send me the lines of
>code at the client side mapping and the DD,
>Thanks & Regards

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

View raw message