SOAP (Simple Object Access Protocol) client and service
SEI -> service endpoint – it does all the soap conversions for soap calls using JAX-WS/RS libs.
Write Web Service Client
- a) Create Java Project
b) import a wsdl by wsimport command
– It will generate all the .class files for web service (Process: looks at WSDL URL, pasrses the wsdl, generates the .java files, compiles all java files into .class byte code, deletes the .java class code. Use “–keep” to keep all java files)
c) Create a java package in your client project and copy all .java files into it.
d) Goto wsdl, look for “wsdl:service name” and “wsdl:port name”
e)Goto added package and use .java files with names which are used in above 2 params.
f)Create the instance of service class.
g)Get the “service port” class interface from it and call the WS method.
#Use “Glassfish” which is an open source application server and comes free with JavaEE SDK.
#Setup app server with eclipse/IntelliJi idea.
Write Web Service
- a) Create a “Web -> Dynamic web project”
b) Create a class with intended method.
c) Mark the class with “@WebService” keyword. That’s all!! A sample web service is created.
Public class ProductCatalog()
List <string> Categories=new ArrayList();
#Deploy the project on Glassfish server by IDE options e.g, right click->RunAs-> Run on server.
#Glasfish provides test interfaces where you can provide input params for methods and see the output.