axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pallapolu, Sudhir" <SPallap...@lanierhealthcare.com>
Subject RE: .Net compatible Serializers/Deserializers for HashMap and col lect ions
Date Wed, 22 Oct 2003 15:38:03 GMT
Thanks for the information... unfortunately the hashmaps I'm using do not
have a fixed set of keys. 
I guess I will have to write a layer to convert the incompatible types to
javabean type objects.
 
-sudhir
 
-----Original Message-----
From: joao.lopes@santander.pt [mailto:joao.lopes@santander.pt] 
Sent: Wednesday, October 22, 2003 11:19 AM
To: axis-user@ws.apache.org
Cc: jorge.paulo@santander.pt
Subject: RE: .Net compatible Serializers/Deserializers for HashMap and col
lect ions
 
I have the same problem.
Ian (ian_d_stewart@bankone.com <mailto:ian_d_stewart@bankone.com> ) sugested
the following:
 
"If your hashtable has a pre-determined set of keys, the easiest way would
be to create a JavaBean that represents the return data, and use the
BeanSerializer/Deserializer via the <beanMapping> element in your WSDD.
 
Example:
 
public class BeanExample {
    public BusinessBean business(String input) {
     ...
    }
 
    public BusinessBean allBusinesses() {
        ...
    }
}
 
<service name="BeanExample">
    <parameter name="className" value="BusinessExample"/>
    <parameter name="allowedMethods" value="business,allBusinesses"/>
    <beanMapping qname="biz:Business" languageSpecificType
="java:BusinessBean" xmlns:biz="urn:Business"/>
</service>
 
Now the return value of business() will be encoded as a complex data type of
type 'Business' and the return value of allBusinesses() will be encoded as a
SOAP array of Business elements, which even .NET should be able to
understand."
 
Take a look at the JAX-RCP:JSR-101, Chapter 4 (WSDL/XML to Java Mapping),
Section 4.2.3 (XML Struct and Complex Type):
 
"An XML struct maps to a JavaBeans class with the same name as the type of
the XML struct. The mapped JavaBeans class provides a pair of getter and
setter methods for each property mapped from the member elements of the XML
struct."
 
So, this means that if you have an hashtable with a fixed set of keys (Key1
and Key2 on the example) you can have a class like this:
 
public class JavaBeanExample {
  // Values.
  private String value1;
  private String value2;
 
  // Setters.
  public void setKey1Value(String value1) {
    this.value1 = value1;
  }
 
  public void setKey1Value(String value2) {
    this.value2 = value2;
  }
 
  // Getters.
  public String getKey1Value() {
    return this.value1;
  }
 
  public String getKey2Value() {
    return this.value2;
  }
}
 
In my case I have a Java API with several public methods that return
Hashtables with fixed keys. This is exactly what I need to expose in an
interop Web Service.
But, if I have to send JavaBeans over the wire how can I fill the values on
my been, by making shure the API is called?
Does the following work for each API call?
 
public class JavaBeanExample {
  // Values.
  private String value1;
  private String value2;
 
// Constructor
  public JavaBeanExample (String inputParameterPassedToJavaAPI)
  {
    Hashtable apiCallingResult = new Hashtable();
    JavaApi javaApi = new JavaApi(); // we would have to import this...
    apiCallingResult =
javaApi.someMethodThatReturnsAnHashtable(inputParameterPassedToJavaAPI);
    ...
    and now that we have the hashtable we need to fill the bean values using
the setters.
    ---
  }
 
  // Setters.
  public void setKey1Value(String value1) {
    this.value1 = value1;
  }
 
  public void setKey1Value(String value2) {
    this.value2 = value2;
  }
 
  // Getters.
  public String getKey1Value() {
    return this.value1;
  }
 
  public String getKey2Value() {
    return this.value2;
  }
}
 
Again *ANY* help is welcome.
 
John
-----Original Message-----
From: Pallapolu, Sudhir [mailto:SPallapolu@lanierhealthcare.com]
Sent: Quarta-feira, 22 de Outubro de 2003 15:25
To: 'axis-user@ws.apache.org'
Subject: .Net compatible Serializers/Deserializers for HashMap and collect
ions
Hi,
 
I am trying to write a custom serializer for java HashMap class (I want to
be able do this for collections as well.).
 .Net doesn't like the SOAP returned by the default MapSerializer, can any
one help me out by pointing me towards a sample or any existing
implementation. Any help in this area will be thoroughly appreciated. 
 
-sudhir
 
 

Mime
View raw message