You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by emh <em...@pondrings.com> on 2003/05/05 07:57:11 UTC

help with Document service using custom (de)serializers

hi,

i need to create a webservice. the XML messages are predefined and i  
can't change them. i would like to serialize/deserialize to my domain  
model.

my understanding is that the only way to do this is to setup a document  
style service with custom serializer/deserializers but i am having no  
end of trouble setting this up.

to start with i think my client is coded wrong as it isn't even  
generating the message the way i think it should be.

inside the <soapenv:Body> tag i expect to see my XML document:

<ProcessOrder><ApplicationArea>...</ApplicationArea>...</ProcessOrder>

but instead i get something like:

<soapenv:Body>
	<ns1:processOrder xmlns:ns1="http://www.telus.com/external">
		<arg0 href="#id0"/>
	</ns1:processOrder>
	<multiRef id="id0" soapenc:root="0"  
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  
xsi:type="ns2:ProcessOrder"  
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"  
xmlns:ns2="http://www.telus.com/external">
		<ns3:ApplicationArea href="#id1"  
xmlns:ns3="http://www.openapplications.org/oagis"/>
		<ns2:stn xsi:type="xsd:string">6045551234</ns2:stn>
	</multiRef>
	<multiRef id="id1" soapenc:root="0"  
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  
xsi:type="ns4:ApplicationArea"  
xmlns:ns4="http://www.openapplications.org/oagis"  
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
		<ns4:CreationDateTime  
xsi:type="xsd:dateTime">2003-05-05T05:46:41.712Z</ns4:CreationDateTime>
	</multiRef>
</soapenv:Body>

my deploy.wsdd file:

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
	xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

	<service name="VPOPService" style="Document">
		<parameter name="className"  
value="com.telus.vpop.soap.ProcessOrderHandler"/>
		<parameter name="allowedMethods" value="*"/>

		<typeMapping qname="ns:ProcessOrder"  
xmlns:ns="http://www.telus.com/vpop"
			languageSpecificType="java:com.telus.vpop.beans.ProcessOrder"
			 
serializer="com.telus.vpop.soap.serializers.ProcessOrderSerializerFactor 
y"
			 
deserializer="com.telus.vpop.soap.serializers.ProcessOrderDeserializerFa 
ctory"
			encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
		<typeMapping qname="oagis:ApplicationArea"  
xmlns:oagis="http://www.openapplications.org/oagis"
			 
languageSpecificType="java:com.telus.vpop.beans.oagis.ApplicationArea"
			 
serializer="com.telus.vpop.soap.serializers.ApplicationAreaSerializerFac 
tory"
			encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
	</service>
</deployment>

my client code:

public class VPOPClient {
     public static void main(String [] args) throws Exception {
         Options options = new Options(args);
         String endpoint = "http://127.0.0.1:8080/axis/services/";

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

         call.setTargetEndpointAddress( new java.net.URL(endpoint) );
         call.setOperationName( new QName("VPOPService", "processOrder")  
);

         QName processOrderQN = new QName( "http://www.telus.com/vpop",  
"ProcessOrder" );
         QName appAreaQN = new QName(  
"http://www.openapplications.org/oagis", "ApplicationArea" );

         call.registerTypeMapping(ProcessOrder.class, processOrderQN,
                         new  
com.telus.vpop.soap.serializers.ProcessOrderSerializerFactory(),
                         new  
com.telus.vpop.soap.serializers.ProcessOrderDeserializerFactory());
         call.registerTypeMapping(ApplicationArea.class, appAreaQN,
                         new  
com.telus.vpop.soap.serializers.ApplicationAreaSerializerFactory(),
                         new  
com.telus.vpop.soap.serializers.ApplicationAreaDeserializerFactory());

         ProcessOrder message = new ProcessOrder();
         message.setApplicationArea(new ApplicationArea());
         message.setStn("6045551234");

         call.addParameter( "message", processOrderQN, ParameterMode.IN  
);

         call.invoke( new Object [] { message });
}

ProcessOrder is a simple class with 2 members, a String and a  
ApplicationArea which is another simple bean with only a Date field. I  
don't want to use the BeanSerializers as the XML is actually much more  
complicated.

i have seen posts on doing document services where the parameter and  
return types are a Document or Element but i would rather deal with my  
domain model.

any help would be appreciated.

evan.