Downloading and Installing wsimportMonday, July 13th, 2009 with 2 Comments »

The Java Web services book I’m reading right now uses wsimport to show how this tool can generate a client with ease.

  1. Download wsimport at JAX-WS from java.net.  There should be a download link in the menu.  At the time of this article, the latest version 2.1.7 can be downloaded here.
  2. Download the file and put it to a directory like C:/Java and execute by double clicking on the JAR file if you are on Windows
  3. From the extracted files, set the CLASSPATH environmental variable in Windows to point to the bin folder

Now you can run wsimport from the command prompt and have all sorts of fun.

Notes - Java Web Services: Up and Running Chapter 1Friday, July 10th, 2009 with No Comments »

A simple web service:

HelloWorldServer.java
package com.codelol.hws;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
/*
* The Service Endpoint Inteface (SEI) for the
* HellowWorldServer
*/

@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorldServer {
@WebMethod String getHelloWorld();
@WebMethod String getTimeString();
@WebMethod int getRandomInteger();
}

HelloWorldServerImpl.java
package com.codelol.hws;

import java.util.Date;
import java.util.Random;
import javax.jws.WebService;
/*
* The Service Implementation Bean (SIB) for the HelloWorldServer
*/

@WebService(endpointInterface =”com.codelol.hws.HelloWorldServer”)
public class HelloWorldServerImpl implements HelloWorldServer {
public String getHelloWorld() {
return “Hello World!”;
}

public int getRandomInteger() {
Random r = new Random(123);
return r.nextInt();
}

public String getTimeString() {
return new Date().toString();
}
}

HelloWorldServerPublisher.java
package com.codelol.hws;

import javax.xml.ws.Endpoint;

// Local host is 127.0.0.1:9876

public class HelloWorldServerPublisher {
public static void main(String[] args){
Endpoint.publish(”http://127.0.0.1:9876/hws”, new HelloWorldServerImpl());
}
}

Get updates as often as we post! Subscribe to our full feed or comments feed.