Notes – Java Web Services: Up and Running Chapter 1
Post Info Friday, July 10th, 2009 2:56 pm by Cody Print Print this page

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());
}
}

One Response to “ Notes – Java Web Services: Up and Running Chapter 1 ”

  1. RYAN


    CheapTabletsOnline.Com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. High quality drugs. Order pills online

    Buy:Valtrex.Prednisolone.Human Growth Hormone.Retin-A.Mega Hoodia.Arimidex.Lumigan.Prevacid.Actos.Accutane.Zyban.Synthroid.Petcam (Metacam) Oral Suspension.100% Pure Okinawan Coral Calcium.Nexium.Zovirax….

Leave a Reply

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