The Source for Java Technology Collaboration
User: Password:



Jitendra Kotamraju's Blog

Community: Java Web Services and XML Archives


JAX-WS RESTful Web Service - AJAX client

Posted by jitu on July 21, 2006 at 04:59 PM | Permalink | Comments (1)

You have already seen quite a few examples of JAX-WS clients accessing RESTful clients. Marc's blog. I wrote a sample RESTful webservice using latest mustang JDK(b91).

A inventory store is implemented as a RESTful web service and the inventory items are accessed and updated as URL resources. The client is the browser and uses javascript's XMLHttpRequest to issue HTTP GET, PUT, POST, DELETE requests to the web service. The client's index.html itself is served by jax-ws endpoint. The Web Service implementation is based on JAX-WS Provider endpoints. These endpoints are powered by mustang JDK.

The rest.zip contains sources and run.sh. Once you run run.sh, it shows a URL that can be used from browser.

I tested the example with some browsers like IE, Firefox. IE poses some problems like caching, and doesn't send a default Content-Type with XMLHttpRequest.send(). So I added some extra lines in the index.html to take care of them.

JAX-RPC in java.net maven repository

Posted by jitu on June 27, 2006 at 06:04 PM | Permalink | Comments (0)

I posted JAX-RPC jars in the maven repository. Here are the details: JAXRPC API JAXRPC RI

Your feedback is welcome. One thing remaining is to add source zips along with jars. You might have already seen the push of JAX-WS .

Web Service endpoints in Mustang

Posted by jitu on January 18, 2006 at 05:17 PM | Permalink | Comments (26)

Mustang has a very good support for Web Services. One can create, publish a Web Service very easily. First write the Web Service endpoint implementation, and then use javax.xml.ws.Endpoint API to create and publish the Web Service.
package myws;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@WebService
@SOAPBinding(style=SOAPBinding.Style.RPC)
public class Implementor {
    public int add(int a, int b) {
        return a+b;
    }
}

package myws;

import javax.xml.ws.Endpoint;

public class WSWrapper {
    public static void main(String[] args) {
        Implementor impl = new Implementor();
        // Create and publish the endpoint at the given address
        Endpoint endpoint = Endpoint.publish("http://localhost:8080/add", impl);
    }
}
Compile both the java files and run the java class myws.WSWrapper (Typically one needs to run wsgen before running the program but in this case it is not required). JAXWS runtime created and published a Web Service in publish() method. The WSDL of the Web Service is published at http://localhost:8080/add?wsdl and can be accessed from the browser. Now write a client to access this Web Service !!



Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds