The Bornholtz Group
Feb 06, 2012

Axis Call.setClientHandlers()


Java
Posted: May 23, 2006

We originally deployed code with a client-config.wsdd but this is a bit unweildy when deploying the client to many different systems. What we really wanted to to instead was to call the setClientHandlers(Handler request, Handler response) method on the Call object.

We are using custom serializers for all of our data types but this caused problems. We need to register the TypeMappings so Apache Axis knows how to serialize the objects into XML and back. The original code looked like this:

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

QName qn = new QName(IDTSConstants.DTS_DEFAULT_NAMESPACE, “DTSResponseSignature”);
call.registerTypeMapping(DTSResponseSignature.class, qn,
new BeanSerializerFactory(DTSResponseSignature.class, qn),
new BeanDeserializerFactory(DTSResponseSignature.class, qn));

And everything worked fine when the client handlers were defined in the client-config.wsdd.

However, as soon as we removed the configuration from the client-config.wsdd and added the line:

call.setClientHandlers(this.getRequestHandler(), this.getResponseHandler());

We would get stack traces like this:

java.io.IOException: No serializer found for class com.aes.dts1.serializable.DTSRequestRouting in registry org.apache.axis.encoding.TypeMappingDelegate@9cfec1
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:317)
at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269)
at org.apache.axis.SOAPPart.saveChanges(SOAPPart.java:530)
at org.apache.axis.attachments.AttachmentsImpl.getAttachmentCount(AttachmentsImpl.java:554)
at org.apache.axis.Message.getContentType(Message.java:486)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:343)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.aes.dts1.client.DTSCoreClient.invoke(DTSCoreClient.java:68)
at DTSClientApplication.main(DTSClientApplication.java:86)
Caused by: java.io.IOException: No serializer found for class com.aes.dts1.serializable.DTSRequestRouting in registry org.apache.axis.encoding.TypeMappingDelegate@9cfec1
at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1505)
at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:978)
at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:678)
at org.apache.axis.message.MessageElement.outputImpl(MessageElement.java:1247)
at org.apache.axis.message.SOAPHeaderElement.outputImpl(SOAPHeaderElement.java:250)
at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
at org.apache.axis.message.SOAPHeader.outputImpl(SOAPHeader.java:328)
at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:476)
at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315)
… 17 more

However, after a few days of debugging (argh!!!) it was a simple fix.

Change the registration of the TypeMapping to look like this:

MessageContext ctx = call.getMessageContext();
TypeMapping tm = ctx.getTypeMapping();

QName qn = new QName(IDTSConstants.DTS_DEFAULT_NAMESPACE,
“DTSResponseSignature”);
tm.register(DTSResponseSignature.class, qn,
new BeanSerializerFactory(DTSResponseSignature.class, qn),
new BeanDeserializerFactory(DTSResponseSignature.class, qn));

Print
All content copyright 2006 The Bornholtz Group  •  Bornholtz.com blog