Roland Carlsson wrote:
Hi!
Is it possible with Axis to create stubs "on-the-fly"?

You could potentially do this if you're familiar with writing custom classloaders - effectively you can use the WSDL2JAVA tool and then dynamically load the byte code in the generated class files. I don't think this is the best way to do this but it will work (the Triana project in the UK did this to cope with web services in workflows for example).

The correct way to do this (in my opinion anyway) is to use the WSDL documents describing the web services directly rather than generating stub classes - it is entirely possible to invoke arbitrary services with complex types etc without having to go through any compilation stage at all, by the sounds of it your requirement is something like 'discover all services, invoke service to gather stats, do analysis' - the first part is up to you as is the analysis but you can do the invocation on the fly.

There is a very simple dynamic invocation example in the axis code, the most obvious question you'll have from this example is 'what about complex types?'. In this context a complex type is anything that you would normally have to register a custom serializer for (this is the main thing the stub classes will do for you). If you're not compiling and loading classes on the fly you won't be able to access these types through java classes but that shouldn't really be a problem - soap is all about passing XML documents around so you should be able to intercept the xml representation of the return value and use it directly (this is what we do in our workflow engine when calling complex services).

Our rather more complex dynamic invocation system is visible at http://cvs.sourceforge.net/viewcvs.py/taverna/taverna1.0/src/org/embl/ebi/escience/scuflworkers/wsdl/ with the WSDLBasedProcessor responsible for creating and configuring an axis call object from a WSDL document and the WSDLInvocationTask responsible for using this object to call the service. Yes, this is a lot of code for something that should be fairly simple, no, this is not my fault :)

HTH,

Tom

Reply via email to