I use Apache Axis 1 to serve web services, which automatically converts Java objects into wsdl definitions and soap responses. However it seems that by default Axis serves rpc encoded data by default. Is there a way to coerce it into serving wrapped document literal data instead?
So far the documentation has not helped me much. My service declaration looks like this:
<service name="myservice" provider="java:RPC" use="literal" style="wrapped">
<parameter name="wsdlTargetNamespace" value="http://www.acme.com/"/>
<parameter name="className" value="com.acme.MyService" />
<operation name="doSomething" returnQName="acme:Response">
<documentation>Does something.</documentation>
<fault name="MyException" type="acme:MyException" class="com.acme.MyException" />
</operation>
</service>
Apparently I need to declare fault to get Exceptions working almost properly. (See this post for dealing with custom exceptions.)
However, this still does not work and will give me an exception as-is. I've discovered that I need to add this static method to each of my objects:
public static void registerTypeMapping(Call call) {
final String WSDL_TARGET_NAMESPACE = "http://www.acme.com/";
final QName QNAME = new QName(WSDL_TARGET_NAMESPACE);
call.registerTypeMapping(Reponse.class, QNAME,
new BeanSerializerFactory(Response.class, QNAME),
new BeanDeserializerFactory(Response.class, QNAME));
}
This makes the exceptions go away which is not really a good thing because now nothing happens. I do not receive any XML responses from my service after making these changes. Besides that even if this worked it sucks to add weird static methods to all of my objects.
Am I missing anything? What do I really need do to get proper wrapped document literal support out of Axis 1?