java2db

Create a java web service from WSDL (Top down approach) in Eclipse



In this approach ,we need to create a WSDL (contract) file first , use it (WSDL)  to develop a java web service and implement the business logic.

 

 

Top down and Bottom up approach ( java web service )

 

 

Create a java web service from WSDL (Top down approach) in Eclipse Process to create a java web service from WSDL in Eclipse IDE :

Create a java web service from WSDL (Top down approach) in Eclipse  Step 1 : To create a WSDL file in Eclipse , select File -> New -> Other -> Web Service -> WSDL File

 

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 2 :Enter  a name (optional) to the WSDL file (Ex : countryCapital.wsdl)  and click Next button .

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 3 : Select a SOAP Binding Option and click Finsh button .

 

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 4 : The below design appears in the Eclipse editor .

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 5 : change the names according to the requirement.

countryCapital  (in the left side box):  Service name .

countryCapitalSOAP : Service Port.

http://www.example.org/ :  End point URL.

countryCapital  (in the right side box) : Port Type.

getCapitalName (top) : It is the operation.

 

Note : the middle small box represents the binding and we can rename it .

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 6 : Click the right arrows in the above design .So that you can see the  in and out parameters .

Note : We can change the type of  in and out parameters by selecting the drop down (In this example i kept the default in and out types) .Now our simple WSDL file is ready .

 

Creating Web service from WSDL :
Create a java web service from WSDL (Top down approach) in Eclipse Step 7 : Create a dynamic web project first and right click on it , select File -> New -> Other -> Web Service -> Web Service   and click Next .

 

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 8 : Select Web Service Type  (Top down java bean Web Service) and  specify the WSDL file path  in Service definition .Make sure that the server is running and  Click finish button.

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 9 : Finally , the Web  Service is created in the source directory like below .

 

 

Create a java web service from WSDL (Top down approach) in Eclipse Step 10 : Implement the business logic in the CountryCapitalSOAPImpl.java  class , add @WebService ,@WebMethod annotations . Deploy the project.

To test the Web Service use the SoapUI (example) or create a simple client (example) .




Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to create WCF web service in C# .NET ( visual studio 2013 )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)
Java RESTful web service example in maven using JAX-RS
   [will not be published]



^ <