//TimeClient.java
package MSCCS.Shiv21;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;
class TimeClient
{public static void main(String[] args)throws Exception
{URL url=new URL("http://127.0.0.1:9876/one?wsdl");
QName qname=new QName("http://Shiv21.MSCCS/","TimeServerImplService");
Service service=Service.create(url,qname);
TimeServer eif=service.getPort(TimeServer.class);
System.out.println(eif.getTimeAsString());
System.out.println(eif.getTimeAsElapsed());}}
//TimeServer.java
package MSCCS.Shiv21;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style=Style.RPC)
public interface TimeServer
{@WebMethod String getTimeAsString();
@WebMethod long getTimeAsElapsed();
}
////TimeServerImpl.java
package MSCCS.Shiv21;
import java.util.Date;
import javax.jws.WebService;
@WebService(endpointInterface="MSCCS.Shiv21.TimeServer")
public class TimeServerImpl
{public String getTimeAsString()
{return new Date().toString();}
public long getTimeAsElapsed()
{return new Date().getTime();}}
////TimeServerPublisher.java
package MSCCS.Shiv21;
import javax.xml.ws.Endpoint;
public class TimeServerPublisher
{public static void main(String[] args)
{Endpoint.publish("http://127.0.0.1:9876/one?wsdl",new TimeServerImpl());}}
/*
CMD 1:
D:MSCCS/Shiv21>javac *.java
D:> java MSCCS.Shiv21.TimeServerPublisher
CMD-2
D:>java MSCCS.Shiv21.TimeClient
*/
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter