aspose file tools*
The moose likes Web Services and the fly likes Apache axis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Apache axis" Watch "Apache axis" New topic
Author

Apache axis

Sunil Telkar
Greenhorn

Joined: Jul 12, 2006
Posts: 2
axis.jar in apache axis comes with BeanSerializer.java and BeanDeserializer.java. These two classes are used by JAVA2WSDL and WSDL2JAVA respectively to serialize and deserialize classes that strictly adhere to java bean convention(null constructor and simple getters and setters).
I want to write my own serializer and deserializer. But i dont know how to make JAVA2WSDL and WSDL2JAVA utilities to use them. I have searched the official axis website. There is no documentation in this case.
If anybody has written own custom serializer and deserializer and have serialzied and deserialized your objects successfully. Please share the way to do the same.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
Welcome to JavaRAnch.

The Axis documentation talk about how to do custom serialization. You don't need to adapt the tools, just the deployment descriptor.


Ping & DNS - my free Android networking tools app
Sunil Telkar
Greenhorn

Joined: Jul 12, 2006
Posts: 2
I wrote a CustomBeanSerializer.java and CustomBeanDeSerializer.java.
My deploy.wsdd looks as follows:

<service name="userservice" provider="java:RPC" style="rpc" use="encoded">
<parameter name="wsdlTargetNamespace" value="urn:com.manheim.ws"/>
<parameter name="wsdlServiceElement" value="IUserServiceService"/>
<parameter name="schemaUnqualified" value="http://beans.manheim.com,urn:com.manheim.ws"/>
<parameter name="wsdlServicePort" value="userservice"/>
<parameter name="className" value="client.UserserviceSoapBindingImpl"/>
<parameter name="wsdlPortType" value="IUserService"/>
<parameter name="typeMappingVersion" value="1.2"/>
<operation name="getRoles" qname="operNS:getRoles" xmlns perNS="urn:com.manheim.ws" returnQName="getRolesReturn" returnType="rtns:UserRole" xmlns:rtns="http://beans.manheim.com" soapAction="" >
<parameter qname="user" type="tns:User" xmlns:tns="http://beans.manheim.com"/>
<parameter qname="appCode" type="tns:string" xmlns:tns="http://schemas.xmlsoap.org/soap/encoding/"/>
</operation>
<parameter name="allowedMethods" value="getRoles"/>
<parameter name="scope" value="Session"/>

<typeMapping
xmlns:ns="http://beans.manheim.com"
qname="ns:User"
type="java:com.manheim.beans.User"
serializer="com.manheim.client.CustomBeanSerializerFactory"
deserializer="com.manheim.client.CustomBeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
<arrayMapping
xmlns:ns="urn:com.manheim.ws"
qname="ns:ArrayOf_soapenc_string"
type="java:java.lang.String[]"
innerType="cmp-ns:string" xmlns:cmp-ns="http://www.w3.org/2001/XMLSchema"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
<typeMapping
xmlns:ns="http://beans.manheim.com"
qname="ns:UserRole"
type="java:com.manheim.beans.UserRole"
serializer="com.manheim.client.CustomBeanSerializerFactory"
deserializer="com.manheim.client.CustomBeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
</service>

What i did is i typed the following url in my browser
http://localhost:8080/axis/services/userservices?wsdl
I got the wsdl file.
Now i want to create java classes from this wsdl file.
To do so i typed the following:
java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -p client userservice.wsdl
I opened UserRole.java file
It has 2 methods as follows:

/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}

/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}

Here you can see that getSerializer and getDeserializer methods are returning BeanSerializer and BeanDeserializer respectively instead of
CustomBeanSerializer and CustomBeanDeserializer.
This is happening inspite of correct definition in server-config.wsdd file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apache axis