How to call web service from Ant script or from Jenkins?

I am using Ant Script in Jenkins to handle the deployment of my files. What I want to do is call the url that the web service has. My question is: how can I do this from Ant Script or from Jenkins?

Thanks in advance, Monte

+5
source share
4 answers

Option 1: get task

Ant to get the task can be used to call web services, but it is limited to GET operations. Only works for very simple web services.

Option 2: curl

Call the unix curl command to invoke the web service (see post examples)

<target name="invoke-webservice"> <exec executable="curl"> <arg line="-d 'param1=value1&param2=value2' http://example.com/resource.cgi"/> </exec> </target> 

Note:

The curl command can also be called as a post post action in Jenkins

Option 3: Groovy ANT Task

If you need a cross platform and flexible solution, embed a Groovy script in your assembly to invoke the web service.

 <target name="invoke-webservice"> <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/> <groovy> import static groovyx.net.http.ContentType.JSON import groovyx.net.http.RESTClient def client = new RESTClient("http://localhost:5498/") def response = client.put(path: "parking_tickets", requestContentType: JSON, contentType: JSON) log.info "response status: ${response.status}" </groovy> </target> 

Option 4: Groovy Jenkins post build

Use the Groovy Postbuild plugin to invoke a web service.

Option 5: ANT HTTP Task

Ant HTTP task is an alternative to Groovy task above

+20
source

You can:

  • Deploy a WebService client with Java (for example, Netbeans can generate it in seconds).
  • Load the customer jar into subversion where you can access Jenkins.
  • Run client from ANT.
  <target name = "run">
           <java jar = "ws_client / WSClient.jar" />
      </target> 
0
source

Related to the question - how to call WebServices from Ant. In my case, Anteater helped to call correctly and get an answer from a semi-arid business. http://aft.sourceforge.net/index.html

 <soapRequest> 

This is a task that you can take a look at.

0
source

Take a look at Groovy-wslite . The project page can be found here . Works like a charm, easy to integrate and intuitive to use. Today I had a similar problem, and in my question / answer I gave a code example: Axis2 with complexTypes in Groovy

0
source

All Articles