I have the same problem.
Ian ([EMAIL PROTECTED]) 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:[EMAIL PROTECTED]
Sent: Quarta-feira, 22 de Outubro de 2003 15:25
To: '[EMAIL PROTECTED]'
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

 

 

Reply via email to