SOAP

JAX-WS Web Service Example Using Eclipse(STS)

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<p>In this tutorial &comma; we will create hello world <b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;what-is-soap&sol;" target&equals;"&lowbar;blank" rel&equals;"noopener">SOAP <&sol;a><&sol;b>web service example in eclipse&lpar;STS&rpar;&period; <b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;eclipse-shortcuts&sol;" target&equals;"&lowbar;blank" rel&equals;"noopener">Eclipse &lpar;STS&rpar;<&sol;a><&sol;b> provides good API for creating web services&period; <b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;eclipse-shortcuts&sol;" target&equals;"&lowbar;blank" rel&equals;"noopener">Eclipse&lpar;STS&rpar;<&sol;a> <&sol;b>will do all work for you-creating <b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-wsdl&sol;" target&equals;"&lowbar;blank" rel&equals;"noopener">WSDL<&sol;a><&sol;b>&comma; stub&comma; endpoints etc&period;<&sol;p>&NewLine;<p>Steps for creating <b>web services<&sol;b> in <b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;eclipse-shortcuts&sol;" target&equals;"&lowbar;blank" rel&equals;"noopener">eclipse&lpar;STS&rpar;<&sol;a><&sol;b>&colon;<&sol;p>&NewLine;<p><b>1&period; Create new dynamic web project and name it &&num;8220&semi;<i>WebService<&sol;i>&&num;8220&semi;&period;<&sol;b><&sol;p>&NewLine;<div id&equals;"ads-id" align&equals;"center"><&sol;div>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts2&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>2&period; Create new package named &&num;8220&semi;<i>com&period;dineshonjava&period;com<&sol;i>&&num;8220&semi;<&sol;b><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts3&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>3&period;Create a simple java class named &&num;8220&semi;<i>HelloWorld&period;java<&sol;i>&&num;8220&semi;<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;ws&semi; &NewLine; &NewLine;import javax&period;jws&period;WebMethod&semi; &NewLine;import javax&period;jws&period;WebService&semi; &NewLine;import javax&period;jws&period;soap&period;SOAPBinding&semi; &NewLine;import javax&period;jws&period;soap&period;SOAPBinding&period;Style&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; Service Endpoint Interface &NewLine; &ast;&sol; &NewLine; &NewLine;&commat;WebService &NewLine;&commat;SOAPBinding&lpar;style &equals; Style&period;RPC&rpar; &NewLine;public interface HelloWorld &lbrace; &NewLine; &commat;WebMethod &NewLine; String sayHelloWorld&lpar;String name&rpar;&semi; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<p><b>4&period; Right click on<i> project-&gt&semi;new-&gt&semi;web service<&sol;i><&sol;b><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts1&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>5&period; Click on <i>next<&sol;i>&period;<&sol;b><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts-1&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p>In service implementation text box&comma;write fully qualified class name of above created class <b>&lpar;com&period;dineshonjava&period;ws&period;HelloWorldImpl&rpar;<&sol;b> and move both above slider to maximum level &lpar;i&period;e&period; <b>Test service and Test Client level&rpar;<&sol;b> and click on finish&period; You are done&excl;&excl; A new project named &&num;8220&semi;<i><b>WebServiceClient<&sol;b><&sol;i>&&num;8221&semi; will be created in your work space&period;<&sol;p>&NewLine;<p><b>6&period; Click on <i>next<&sol;i>&period;<&sol;b><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts5-1&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts2-1&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>7&period; Start Server&period;<&sol;b><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts3-1&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>8&period; After clicking start server&comma;eclipse will open test web service API&period; With this test API&comma; you can test your web service&period;<&sol;b><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;websts4&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b><i>Note<&sol;i>&colon; Sometimes we get the following exception when we creating Web Service using Eclipse or STS<&sol;b><&sol;p>&NewLine;<p>IWAB0506E Error when copying Axis jar files to web project<br &sol;>&NewLine;java&period;io&period;FileNotFoundException&colon; &sol;lib&sol;saaj&period;jar<br &sol;>&NewLine;at org&period;eclipse&period;osgi&period;framework&period;internal&period;protocol&period;bundleentry&period;Handler&period;findBundleEntry&lpar;Handler&period;java&colon;44&rpar;<br &sol;>&NewLine;at org&period;eclipse&period;osgi&period;framework&period;internal&period;core&period;BundleResourceHandler&period;openConnection&lpar;BundleResourceHandler&period;java&colon;168&rpar;<br &sol;>&NewLine;at java&period;net&period;URL&period;openConnection&lpar;Unknown Source&rpar;<br &sol;>&NewLine;at java&period;net&period;URL&period;openStream&lpar;Unknown Source&rpar;<br &sol;>&NewLine;at<&sol;p>&NewLine;<h1><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;06&sol;filenotfoundexception-in-eclipse-when&period;html" target&equals;"&lowbar;blank" rel&equals;"noopener">FileNotFoundException in Eclipse when creating a webservice<&sol;a><&sol;h1>&NewLine;<h1><&sol;h1>&NewLine;<p><i><b>References<&sol;b><&sol;i><br &sol;>&NewLine;<i><b><a href&equals;"http&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Web&lowbar;service" target&equals;"&lowbar;blank" rel&equals;"noopener">Wikipedia for Web Service<&sol;a><&sol;b><&sol;i><&sol;p>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<div style&equals;"background-color&colon; pink&semi; border-width&colon; thin&semi; text-align&colon; center&semi;"><b>&lt&semi;&lt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jax-ws-web-service-tutorial&sol;">Previous<&sol;a> &lt&semi;&lt&semi;   &vert;&vert; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;core-java-baby-step-to-be-best-java-ian&sol;">Index <&sol;a>&vert;&vert;   &gt&semi;&gt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;filenotfoundexception-in-eclipse-when&sol;">Next<&sol;a> &gt&semi;&gt&semi;<&sol;b><&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jax-ws-web-service-tutorial&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jax-ws-hello-world-example&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '436'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago