Axis2 with complexTypes in Groovy

So, I have a couple of ANT scripts using Groovy to handle complex calculations that a normal ANT cannot do (at least afaik). I am trying to access the Axis2 web service using a SOAP envelope through Groovy. The request and response are fairly simple, with the exception of two complexType attributes (one in the request, one in the response).

The first thing I came across was Groovy Soap . It is pretty easy to use, you just instantiate SoapClient and call the web service method. Unfortunately, it cannot handle complexType attributes in the request that I need:

Current limits:

....

4: Custom data types cannot be processed on the client side when using the Groovy SOAP module with the current groovy version -1.0.

Then I read a lot about GroovyWS . I created my Grape configuration file in my user.home , javac and $ GROOVY_HOME (basically did everything as described on the project quick start page), the Vineyard somehow restored Ivy when I first ran the script (I have no experience working with Grape, but I suspect it is very similar to Maven).

Then my simple script started:

 @Grab(group='org.codehaus.groovy.modules', module='groovyws',version='0.5.2') import groovyx.net.ws.WSClient proxy = new WSClient("http://127.0.0.1/axis2/services/ReleaseService?wsdl", this.class.classLoader) proxy.initialize() 

Unfortunately, I could not even initialize the web client (without the Groovy Soap library in the classpath):

 SEVERE: Could not compile java files for http://127.0.0.1/axis2/services/ReleaseService?wsdl. Caught: java.lang.IllegalStateException: Unable to create JAXBContext for generated packages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "com.intershop.qa.tae.ws.xsd" doesnt contain ObjectFactory.class or jaxb.index java.lang.IllegalStateException: Unable to create JAXBContext for generated packages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated [...] 

Using the Groovy Soap library (which seems to overload some GroovyWS functions) in the class path that I have:

 Caught: java.lang.NoSuchMethodError: javax.wsdl.xml.WSDLReader.readWSDL(Ljavax/wsdl/xml/WSDLLocator;Lorg/w3c/dom/Element;)Ljavax/wsdl/Definition; java.lang.NoSuchMethodError: 

which looks very similar to the error I received when I first used Groovy Soap.

So my question is:. How can I communicate with the Axis2 web service using complexType parameters through ANT. I'm not limited to Groovy, but for deployment reasons (~ 50 VM snapshots) I need something simple. The Java client worked, but since deployment is quite a bit of effort (especially if I want to change stuff in the future), I need something that is closer to ANT and easier to deploy.

Thanks in advance for suggestions from other technologies or to fix ideas for my GroovyWS implementation.

0
source share
2 answers

I finally came up with a solution: groovy -wslight actually solved my problem and finally was able to easily deploy and access the web service without problems / exceptions.

script:

 @Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.1') import wslite.soap.* def client = new SOAPClient("http://127.0.0.1/axis2/services/ReleaseService") def response = client.send { body { myFunction(xmlns:"http://my.namespace.com") { stringParameter("6.3.0.0") status() { value("default") } mode() { value("full") } } } } 

Where status and mode are complexTypes , which consist of a single attribute "value" (as an example).

 println(response.myFunctionResponse.return) 

returns the object returned by the web service. Of course, token names depend on WSDL. In my case, the response of the request is called myFunctionResponse , which has a field name="return" and gives me a complexType object. The fields of the object can be obtained in accordance with the names specified in the WSDL:

 println(response.myFunctionResponse.return.location) // gives me the field value of the field "location" for my complexType 
0
source

I had a similar problem when using JDK 1.7. Switching to JDK 1.6 decided for me.

0
source

All Articles