Create web service in Bottom Up approach using command line


Create Service Interface MyJaxWSSEI.java

package in.malliktalksjava.ws;

import in.malliktalksjava.ws.pojo.*;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.WebParam.Mode;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

@WebService(name = “MyJaxWSHello”,
targetNamespace = “http://malliktalksjava.in”,
wsdlLocation = “http://malliktalksjava.in/MyJaxWS?wsdl”)
@SOAPBinding(style=Style.RPC, use=Use.LITERAL)
public interface MyJaxWSSEI {

@WebMethod(operationName=”getJXWsRes”)
@RequestWrapper(targetNamespace=”http://malliktalksjava.in/ws/types”,
className=”java.lang.String”)
@ResponseWrapper(targetNamespace=”http://malliktalksjava.in/ws/types”,
className=”in.malliktalksjava.ws.JXRes”)
@WebResult(targetNamespace=”http://malliktalksjava.in/ws/types”,
name=”JXWsRes”)
public JXRes getJXWsRes(
@WebParam(targetNamespace=”http://malliktalksjava.in/ws/types”,
name=”name”,
mode=Mode.IN)
String name
);

}

 

Create Implementation class for the above interface – MyJaxWSSEIImpl.java

package in.malliktalksjava.ws;

import in.malliktalksjava.ws.pojo.*;
import javax.jws.WebService;

@WebService(endpointInterface=”in.malliktalksjava.ws.MyJaxWSSEI”,
targetNamespace=”http://malliktalksjava.in”,
portName=”MyJaxWSSEIPort”,
serviceName=”MyJaxWSHelloService”)
public class MyJaxWSSEIImpl implements MyJaxWSSEI {

/**
* Default Constructor
*/
public MyJaxWSSEIImpl() {

}

/* (non-Javadoc)
* @see in.malliktalksjava.ws.MyJaxWSSEI#getJXWsRes(java.lang.String)
*/
@Override
public JXRes getJXWsRes(String name) {
JXRes jxRes = new JXRes();
jxRes.setMessage(“Hello”);
jxRes.setName(name);
return jxRes;
}

}

Create Required Model object JXRes.java

package in.malliktalksjava.ws.pojo;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class JXRes {
protected String message;
protected String name;
/**
*
*/
public JXRes() {
super();
}
/**
* @return the id
*/
public String getMessage() {
return message;
}
/**
* @param id the id to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

}

Create Main Class JXResTest.java

package in.malliktalksjava.ws.main;

import javax.xml.ws.Endpoint;
import in.malliktalksjava.ws.*;

public class JXResTest {
public static void main(String[] args ){
Endpoint.publish(“http://localhost:8080/MyJaxWSService”, new MyJaxWSSEIImpl());
}
}

 

Compile Java Classes in command prompt:

compileclass

Run the class

runmainclass

Verify the service : http://localhost:8080/MyJaxWSService?wsdl

wsdl

 

Advertisements
About

I born in Good cultural place called India. My family is traditional family. We fallow all Indian traditions.

Tagged with: , , ,
Posted in JAVA, Web Services

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 676 other followers

Calendar
December 2016
M T W T F S S
« Dec   Aug »
 1234
567891011
12131415161718
19202122232425
262728293031  
Mallikarjun Gunda

This is Mallikarjun Gunda, I am working as a software professional. Blogging is my Passion. This blog contains the posts on Java related technologies and programming languages. I am happy to share my knowledge through the blogs.

Blog Stats
  • 224,246 hits
IndiBlogger
malliktalksjava.wordpress.c...
70/100
All tags
AngularJS Apache Cassandra Arrays in Java Cassandra Cassandra Database Cassandra examples client stubs creating a java web service creating a web service using java difference between interface and abstract class Differences between SOAP and RESTfull webservices Display div as Overlay using JQuery download the spring basic application File directory Generating webservice client stubs Hibernate hibernate exceptions How to display over using JQuery how to generated web service client stubs in STS How to implement Spring basic application how to write singleton design pattern in java interface in java Java Java Arrays Java Example Programs Java examples Java interview questions java programs java project Java sample Programs Java Script JavaScript JavaServer Faces Java Sorting alogorithms Java Tutorials javatutorials Java Web services JDBC open shift openshift Overlay implementation using JQuery Overlay in JQuery POI API POI Examples public class public static void main Redhat OpenShift representational state transfer Restfull webservices sample programs in java Service-oriented architecture Singleton design pattern in java SOAP SOAP Webservices software Spring Framework Spring Interview Questions Spring MVC Spring MVC Example program Spring MVC sample Program Spring Sample Programs Spring Tutorials Struts technology Top Java Interview questions w3c dom Web service web service client Web Service Description Language webservices Web services writing singleton design pattern in Java WSDL Xml xml parsers