No answer to my question yet. I'm trying to create a Axis client Call object within an Axis web application (i.e., within the same Servlet context). The tricky thing is that I have some custom server configuration (typemappings/beanmappings) in the server-config.wsdd that should affect the Call as well. This seems like a relatively common scenario -- attempting to create a grid of Axis servers that publish and consume each other's Web Services, while using the same <typeMappings>.
Here is a snippet that I currently use to get the job done:
EngineConfiguration config = new SimpleProvider(axis.getClientEngine().getConfig()) { public TypeMappingRegistry getTypeMappingRegistry() { return axis.getTypeMappingRegistry(); } }; sub.service = new Service(config);
That's not very straightforward, but it works. (See my earlier email below for some alternate approaches that failed.) Perhaps this code will incite someone to criticize me and provide a better solution.
Thanks!
Jim
p.s. If it turns out that the cleanest solution is to have a client-config.wsdd file in the WEB-INF directory, then I suppose I could factor out the <typemappings> into a third file, and include them as entities -- how's that? (again, I'm trying to avoid config redundancy/cruftiness.)
Jim Carlson wrote:
Hello,
I'm trying to determine the correct way to invoke a web service, from within a servlet container context, which is itself running an Axis server.
My specific scenario is that I'm running Tomcat 4.1, and I have a webapp which contains the Axis jars and server-config.wsdd. This webapp should both publish and consume my web services. (In each case, the other party is another, similar Tomcat/Axis server.) In addition, I have some custom typemappings that need to work on both client and server end.
I have no problem configuring the Axis server to publish my services with the custom typemappings. However, I don't know how to create a Service and a Call, from within the same webapp, which use the typemappings from server-config.wsdd. It seems like there should be an easy way to do this (without replicating config information anywhere).
I can get an instance of AxisServer by calling AxisServletBase.getEngine(someOtherServlet). This AxisServlet has the typemappings from server-config.wsdd. Next, I've tried the following techniques:
new Service(axisServer.getConfig()).createCall();
new Service(axisServer.getClientEngine().getConfig()).createCall();
new Service().setTypeMappingRegistry(axisServer.getTypeMappingRegistry());
... and some other permutations as well. In the first case, Call.invoke() behaves very oddly, I think because it has server-side handlers instead of client-side handlers. In both the first and second cases, a subsequent check of Service.getTypeMappingRegistry() shows that my custom mappings did not actually transfer over. In the third case.... well here's the implementation of Service.setTypeMappingRegistry() from axis/client/Service.java:
public void setTypeMappingRegistry(TypeMappingRegistry registry) throws ServiceException { }
A no-op. That was a fun surprise. Anyhow, I will continue digging through the source, but I thought someone on this list would probably already know the *correct* way to acheive this. Note that I am trying to avoid having a second client.wsdd file, or programmatically copying over the individual Mappings, because both of these techniques unnecessarily replicate configuration data. I hope there is something better.
Thanks!
Jim