{"id":31636,"date":"2016-01-18T15:00:48","date_gmt":"2016-01-18T13:00:48","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=31636"},"modified":"2016-01-18T09:18:26","modified_gmt":"2016-01-18T07:18:26","slug":"jax-ws-web-service-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/","title":{"rendered":"JAX-WS Web Service Example"},"content":{"rendered":"<p>In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API&#8217;s provided by Java for implementing Web Service.<br \/>\nHere, we shall start by learning what web services are, their architecture, followed by implementation of server and client. We shall also learn the different variants of XML Web Service and the WSDL file which is the contract that defines a Web Service.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#WhatAreWebServices\">1. What are Web Services?<\/a><\/dt>\n<dt><a href=\"#WebServiceServer\">2. Implementing JAX-WS Web Service Server<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#SEI\">2.1 Implementing Service Endpoint Interface<\/a><\/dt>\n<dt><a href=\"#SIB\">2.2 Implementing Service Implementation Bean<\/a><\/dt>\n<dt><a href=\"#Publisher\">2.3 Publishing Endpoint<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#WSDL\">3. WSDL explained<\/a><\/dt>\n<dt><a href=\"#DOCUMENT\">4. DOCUMENT style Web Services<\/a><\/dt>\n<dt><a href=\"#Client\">5. Testing Web Service<\/a><\/dt>\n<dt><a href=\"#Download\">6. Download the source code<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2><a name=\"WhatAreWebServices\"><\/a>1. What are Web Services?<\/h2>\n<p>Web service is a distributed <i>webified<\/i> application typically delivered over <i>HTTP<\/i>. The 3 key features of Web Services are:<\/p>\n<ol type=\"1\">\n<li>Open infrastructure<\/li>\n<li>Language transparency<\/li>\n<li>Modular design<\/li>\n<\/ol>\n<p>The major appeal of Web Services are language transparency, server and client can be written in different languages. And this language transparency is the key to web service <i>interoperability<\/i>.<\/p>\n<p>Web service can be divided into 2 groups, <i>SOAP<\/i> and <i>REST<\/i>. <\/p>\n<p>SOAP stands for Simple Object Access Protocol and is a XML based web service. In this example, our entire focus shall be on SOAP based web service.<\/p>\n<p>REST stands for REpresentational State Transfer. REST doesn&#8217;t have any standard like SOAP has and works using standard HTTP methods like <code>PUT<\/code>, <code>GET<\/code>, <code>DELETE<\/code> and <code>POST<\/code>.<\/p>\n<p>Coming back to SOAP, it follows a simple architecture, client uses SOAP libraries to construct request and send it to server. Server uses SOAP libraries to decode request and construct corresponding response.<\/p>\n<p><figure id=\"attachment_31648\" aria-describedby=\"caption-attachment-31648\" style=\"width: 567px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/SOAPArchitecture.jpg\" rel=\"attachment wp-att-31648\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/SOAPArchitecture.jpg\" alt=\"SOAP Architecture\" width=\"567\" height=\"358\" class=\"size-full wp-image-31648\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/SOAPArchitecture.jpg 567w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/SOAPArchitecture-300x189.jpg 300w\" sizes=\"(max-width: 567px) 100vw, 567px\" \/><\/a><figcaption id=\"caption-attachment-31648\" class=\"wp-caption-text\">SOAP Architecture<\/figcaption><\/figure><\/p>\n<h2><a name=\"WebServiceServer\"><\/a>2. Implementing JAX-WS Web Service Server<\/h2>\n<h3><a name=\"SEI\"><\/a>2.1 Implementing Service Endpoint Interface<\/h3>\n<p>The first step in implementing Web Service server is writing Service Endpoint Interface. This interface defines the methods that shall be exposed by the web service. Let&#8217;s look at one example.<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalculatorI.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebService;\r\nimport javax.jws.soap.SOAPBinding;\r\nimport javax.jws.soap.SOAPBinding.Style;\r\n\r\n@WebService\r\n@SOAPBinding(style = Style.RPC)\r\npublic interface CalculatorI {\r\n\t@WebMethod\r\n\tint add(int a, int b);\r\n\r\n\t@WebMethod\r\n\tint subtract(int a, int b);\r\n\r\n\t@WebMethod\r\n\tint multiply(int a, int b);\r\n\r\n\t@WebMethod\r\n\tint divide(int a, int b);\r\n}\r\n<\/pre>\n<p>In the above program <code>@SOAPBinding<\/code> annotation is used to specify the SOAP messaging style which can either be <code>RPC<\/code> or <code>DOCUMENT<\/code>. This style represents the encoding style of message sent to and fro while using the web service. With <code>RPC<\/code> style a web service is capable of only using simple data types like integer or string. However, <code>DOCUMENT<\/code> style is capable of richer data types for a class let\u2019s say <code>Person<\/code>, which can have attributes like String name, Address address etc.<\/p>\n<p>Also, <code>@WebMethod<\/code> annotation used above specifies that the method represents a web service operation.<\/p>\n<h3><a name=\"SIB\"><\/a>2.2 Implementing Service Implementation Bean<\/h3>\n<p>Nest step is to write the implementation of Service Endpoint Interface which is called Service Implementation Bean.<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalculatorImpl.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport javax.jws.WebService;\r\n\r\n@WebService(endpointInterface = \"com.javacodegeeks.examples.jaxws.CalculatorI\")\r\npublic class CalculatorImpl implements CalculatorI {\r\n\r\n\t@Override\r\n\tpublic int add(int a, int b) {\r\n\t\treturn a + b;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic int subtract(int a, int b) {\r\n\t\treturn a - b;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic int multiply(int a, int b) {\r\n\t\treturn a * b;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic int divide(int a, int b) {\r\n\t\treturn a \/ b;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>In the above program we can see that we have provided an optional element <code>endpointInterface<\/code> to <code>@WebService<\/code> annotation which says that this class is implementation of the mentioned Service Endpoint Interface. <\/p>\n<h3><a name=\"Publisher\"><\/a>2.3 Publishing Endpoint<\/h3>\n<p>Next step and the last step for completing and running the server for this example is running a small program that shall take the Service Implementation Bean object and shall publish this as a web service.<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalcPublisher.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport javax.xml.ws.Endpoint;\r\n\r\npublic class CalcPublisher {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tEndpoint ep = Endpoint.create(new CalculatorImpl());\r\n\t\tep.publish(\"http:\/\/127.0.0.1:10000\/calcServer\");\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>On running the above main program, web service shall be hosted at the URL passed as argument to the <code>publish()<\/code> method in the above program.<\/p>\n<h2><a name=\"WSDL\"><\/a>3. WSDL explained<\/h2>\n<p>To test the Web Service we can open a browser and view the WSDL which stands for Web Service Definition Language. For the web service published in section <a href=\"#Publisher\">2.3<\/a>, the URL to access the WSDL shall be <code>http:\/\/127.0.0.1:10000\/calcServer?wsdl<\/code>. This is the URL at which the Web Service was published followed by <code>?wsdl<\/code>.<\/p>\n<p>Let&#8217;s access this WSDL and save this in a file say <i>calculator.wsdl<\/i>.<\/p>\n<p><span style=\"text-decoration: underline\"><em>calculator.wsdl<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- Published by JAX-WS RI (http:\/\/jax-ws.java.net). RI's version is JAX-WS \r\n\tRI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --&gt;\r\n&lt;!-- Generated by JAX-WS RI (http:\/\/jax-ws.java.net). RI's version is JAX-WS \r\n\tRI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --&gt;\r\n&lt;definitions\r\n\txmlns:wsu=\"http:\/\/docs.oasis-open.org\/wss\/2004\/01\/oasis-200401-wss-wssecurity-utility-1.0.xsd\"\r\n\txmlns:wsp=\"http:\/\/www.w3.org\/ns\/ws-policy\" xmlns:wsp1_2=\"http:\/\/schemas.xmlsoap.org\/ws\/2004\/09\/policy\"\r\n\txmlns:wsam=\"http:\/\/www.w3.org\/2007\/05\/addressing\/metadata\" xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/wsdl\/soap\/\"\r\n\txmlns:tns=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"\r\n\txmlns=\"http:\/\/schemas.xmlsoap.org\/wsdl\/\" targetNamespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\"\r\n\tname=\"CalculatorImplService\"&gt;\r\n\t&lt;types \/&gt;\r\n\t&lt;message name=\"add\"&gt;\r\n\t\t&lt;part name=\"arg0\" type=\"xsd:int\" \/&gt;\r\n\t\t&lt;part name=\"arg1\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"addResponse\"&gt;\r\n\t\t&lt;part name=\"return\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"divide\"&gt;\r\n\t\t&lt;part name=\"arg0\" type=\"xsd:int\" \/&gt;\r\n\t\t&lt;part name=\"arg1\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"divideResponse\"&gt;\r\n\t\t&lt;part name=\"return\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"subtract\"&gt;\r\n\t\t&lt;part name=\"arg0\" type=\"xsd:int\" \/&gt;\r\n\t\t&lt;part name=\"arg1\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"subtractResponse\"&gt;\r\n\t\t&lt;part name=\"return\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"multiply\"&gt;\r\n\t\t&lt;part name=\"arg0\" type=\"xsd:int\" \/&gt;\r\n\t\t&lt;part name=\"arg1\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"multiplyResponse\"&gt;\r\n\t\t&lt;part name=\"return\" type=\"xsd:int\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;portType name=\"CalculatorI\"&gt;\r\n\t\t&lt;operation name=\"add\" parameterOrder=\"arg0 arg1\"&gt;\r\n\t\t\t&lt;input\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/addRequest\"\r\n\t\t\t\tmessage=\"tns:add\" \/&gt;\r\n\t\t\t&lt;output\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/addResponse\"\r\n\t\t\t\tmessage=\"tns:addResponse\" \/&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t\t&lt;operation name=\"divide\" parameterOrder=\"arg0 arg1\"&gt;\r\n\t\t\t&lt;input\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/divideRequest\"\r\n\t\t\t\tmessage=\"tns:divide\" \/&gt;\r\n\t\t\t&lt;output\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/divideResponse\"\r\n\t\t\t\tmessage=\"tns:divideResponse\" \/&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t\t&lt;operation name=\"subtract\" parameterOrder=\"arg0 arg1\"&gt;\r\n\t\t\t&lt;input\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/subtractRequest\"\r\n\t\t\t\tmessage=\"tns:subtract\" \/&gt;\r\n\t\t\t&lt;output\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/subtractResponse\"\r\n\t\t\t\tmessage=\"tns:subtractResponse\" \/&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t\t&lt;operation name=\"multiply\" parameterOrder=\"arg0 arg1\"&gt;\r\n\t\t\t&lt;input\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/multiplyRequest\"\r\n\t\t\t\tmessage=\"tns:multiply\" \/&gt;\r\n\t\t\t&lt;output\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/multiplyResponse\"\r\n\t\t\t\tmessage=\"tns:multiplyResponse\" \/&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t&lt;\/portType&gt;\r\n\t&lt;binding name=\"CalculatorImplPortBinding\" type=\"tns:CalculatorI\"&gt;\r\n\t\t&lt;soap:binding transport=\"http:\/\/schemas.xmlsoap.org\/soap\/http\"\r\n\t\t\tstyle=\"rpc\" \/&gt;\r\n\t\t&lt;operation name=\"add\"&gt;\r\n\t\t\t&lt;soap:operation soapAction=\"\" \/&gt;\r\n\t\t\t&lt;input&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/input&gt;\r\n\t\t\t&lt;output&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/output&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t\t&lt;operation name=\"divide\"&gt;\r\n\t\t\t&lt;soap:operation soapAction=\"\" \/&gt;\r\n\t\t\t&lt;input&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/input&gt;\r\n\t\t\t&lt;output&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/output&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t\t&lt;operation name=\"subtract\"&gt;\r\n\t\t\t&lt;soap:operation soapAction=\"\" \/&gt;\r\n\t\t\t&lt;input&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/input&gt;\r\n\t\t\t&lt;output&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/output&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t\t&lt;operation name=\"multiply\"&gt;\r\n\t\t\t&lt;soap:operation soapAction=\"\" \/&gt;\r\n\t\t\t&lt;input&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/input&gt;\r\n\t\t\t&lt;output&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" \/&gt;\r\n\t\t\t&lt;\/output&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t&lt;\/binding&gt;\r\n\t&lt;service name=\"CalculatorImplService\"&gt;\r\n\t\t&lt;port name=\"CalculatorImplPort\" binding=\"tns:CalculatorImplPortBinding\"&gt;\r\n\t\t\t&lt;soap:address location=\"http:\/\/127.0.0.1:10000\/calcServer\" \/&gt;\r\n\t\t&lt;\/port&gt;\r\n\t&lt;\/service&gt;\r\n&lt;\/definitions&gt;\r\n<\/pre>\n<p>This WSDL file is an XML format describing the web service. This is a strict contract and describes messages and operations at an abstract level. Let&#8217;s understand each tag of the WSDL file to get clear picture:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ol type=\"1\">\n<li><i><strong>types:<\/strong> <\/i>This optional tag represents data types in an XSD. This tag might hold or point to an XSD. If we find this tag as empty as in above WSDL, then it means that the Web Service uses simple data types. For complex data types, <code>DOCUMENT<\/code> style web services are implemented which is explained in next section.<\/li>\n<li><i><strong>message:<\/strong> <\/i>This tag defines the messages that implement the web service. These messages are constructed from messages that are defined in types section, also it defines in out order of messages that represents request response pattern of web service operation.<\/li>\n<li><i><strong>portType:<\/strong> <\/i>This tag represents service as named operations, with each operation using one ore more messages. These operations are defined after method names defined against <code>@WebMethods<\/code> annotation. It is a kind of Java Interface defining the web service at an abstract level.<\/li>\n<li><i><strong>binding:<\/strong> <\/i>This tag is kind of implementation of a Java interface. Here concrete details of web service are present.<\/li>\n<li><i><strong>service:<\/strong> <\/i>This tag contains information about one or more endpoints where web service functionality is available.<\/li>\n<\/ol>\n<h2><a name=\"DOCUMENT\"><\/a>4. Document style Web Services<\/h2>\n<p>Notice that the web service that we implemented in section <a name=\"WebServiceServer\">2<\/a> is using simple or primitive data types. But think of a scenario if we want to return <code>Person<\/code> object based on id. In this case we use Document style web services.<\/p>\n<p>First let&#8217;s implement POJO class <code>Person<\/code>.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Person.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\npublic class Person {\r\n\tprivate int id;\r\n\tprivate String name;\r\n\r\n\tpublic int getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic void setId(int id) {\r\n\t\tthis.id = id;\r\n\t}\r\n\r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n\r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\r\n\tpublic Person(int id, String name) {\r\n\t\tsuper();\r\n\t\tthis.id = id;\r\n\t\tthis.name = name;\r\n\t}\r\n\r\n\tpublic Person() {\r\n\t\tsuper();\r\n\t}\r\n}\r\n<\/pre>\n<p>Next we shall implement a <code>PersonUtil<\/code> class. This utility class shall help in managing <code>Person<\/code> data. In production environment, we might be fetching data from the database.<\/p>\n<p><span style=\"text-decoration: underline\"><em>PersonUtil.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class PersonUtil {\r\n\tprivate static Map map;\r\n\t\r\n\tstatic {\r\n\t\tmap = new HashMap();\r\n\t\tmap.put(1, new Person(1, \"A\"));\r\n\t\tmap.put(2, new Person(2, \"B\"));\r\n\t\tmap.put(3, new Person(3, \"C\"));\r\n\t\tmap.put(4, new Person(4, \"D\"));\r\n\t\tmap.put(5, new Person(5, \"E\"));\r\n\t}\r\n\r\n\tprivate PersonUtil() {\r\n\t}\r\n\r\n\tpublic static Person getPerson(Integer id) {\r\n\t\treturn map.get(id);\r\n\t}\r\n}\r\n<\/pre>\n<p>Next we shall implement Service Endpoint Inteface for <code>DOCUMENT<\/code> style web service.<\/p>\n<p><span style=\"text-decoration: underline\"><em>PersonServiceI.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebService;\r\nimport javax.jws.soap.SOAPBinding;\r\nimport javax.jws.soap.SOAPBinding.Style;\r\n\r\n@WebService\r\n@SOAPBinding(style = Style.DOCUMENT)\r\npublic interface PersonServiceI {\r\n\t@WebMethod\r\n\tPerson getPerson(Integer id);\r\n}\r\n<\/pre>\n<p>Notice here that in the <code>@SOAPBinding<\/code> annotation, <code>style<\/code> attribute has just been changed to <code>DOCUMENT<\/code>.<\/p>\n<p>Service Implementation Bean for the above interface shall be like:<\/p>\n<p><span style=\"text-decoration: underline\"><em>PersonServiceImpl.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport javax.jws.WebService;\r\n\r\n@WebService(endpointInterface = \"com.javacodegeeks.examples.jaxws.PersonServiceI\")\r\npublic class PersonServiceImpl implements PersonServiceI {\r\n\r\n\t@Override\r\n\tpublic Person getPerson(Integer id) {\r\n\t\treturn PersonUtil.getPerson(id);\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>Next task is to publish the web service.<\/p>\n<p><span style=\"text-decoration: underline\"><em>PersonPublisher.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws;\r\n\r\nimport javax.xml.ws.Endpoint;\r\n\r\npublic class PersonPublisher {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tEndpoint ep = Endpoint.create(new PersonServiceImpl());\r\n\t\tep.publish(\"http:\/\/127.0.0.1:10000\/personServer\");\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>On executing this program we can check the WSDL at URL <code>http:\/\/127.0.0.1:10000\/personServer?wsdl<\/code>. Let&#8217;s save this WSDL file as personService.wsdl.<\/p>\n<p><span style=\"text-decoration: underline\"><em>personService.wsdl<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- Generated by JAX-WS RI (http:\/\/jax-ws.java.net). RI's version is JAX-WS \r\n\tRI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --&gt;\r\n&lt;definitions\r\n\txmlns:wsu=\"http:\/\/docs.oasis-open.org\/wss\/2004\/01\/oasis-200401-wss-wssecurity-utility-1.0.xsd\"\r\n\txmlns:wsp=\"http:\/\/www.w3.org\/ns\/ws-policy\" xmlns:wsp1_2=\"http:\/\/schemas.xmlsoap.org\/ws\/2004\/09\/policy\"\r\n\txmlns:wsam=\"http:\/\/www.w3.org\/2007\/05\/addressing\/metadata\" xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/wsdl\/soap\/\"\r\n\txmlns:tns=\"http:\/\/jaxws.examples.javacodegeeks.com\/\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"\r\n\txmlns=\"http:\/\/schemas.xmlsoap.org\/wsdl\/\" targetNamespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\"\r\n\tname=\"PersonServiceImplService\"&gt;\r\n\t&lt;types&gt;\r\n\t\t&lt;xsd:schema&gt;\r\n\t\t\t&lt;xsd:import namespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\"\r\n\t\t\t\tschemaLocation=\"http:\/\/127.0.0.1:10000\/personServer?xsd=1\" \/&gt;\r\n\t\t&lt;\/xsd:schema&gt;\r\n\t&lt;\/types&gt;\r\n\t&lt;message name=\"getPerson\"&gt;\r\n\t\t&lt;part name=\"parameters\" element=\"tns:getPerson\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;message name=\"getPersonResponse\"&gt;\r\n\t\t&lt;part name=\"parameters\" element=\"tns:getPersonResponse\" \/&gt;\r\n\t&lt;\/message&gt;\r\n\t&lt;portType name=\"PersonServiceI\"&gt;\r\n\t\t&lt;operation name=\"getPerson\"&gt;\r\n\t\t\t&lt;input\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/PersonServiceI\/getPersonRequest\"\r\n\t\t\t\tmessage=\"tns:getPerson\" \/&gt;\r\n\t\t\t&lt;output\r\n\t\t\t\twsam:Action=\"http:\/\/jaxws.examples.javacodegeeks.com\/PersonServiceI\/getPersonResponse\"\r\n\t\t\t\tmessage=\"tns:getPersonResponse\" \/&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t&lt;\/portType&gt;\r\n\t&lt;binding name=\"PersonServiceImplPortBinding\" type=\"tns:PersonServiceI\"&gt;\r\n\t\t&lt;soap:binding transport=\"http:\/\/schemas.xmlsoap.org\/soap\/http\"\r\n\t\t\tstyle=\"document\" \/&gt;\r\n\t\t&lt;operation name=\"getPerson\"&gt;\r\n\t\t\t&lt;soap:operation soapAction=\"\" \/&gt;\r\n\t\t\t&lt;input&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" \/&gt;\r\n\t\t\t&lt;\/input&gt;\r\n\t\t\t&lt;output&gt;\r\n\t\t\t\t&lt;soap:body use=\"literal\" \/&gt;\r\n\t\t\t&lt;\/output&gt;\r\n\t\t&lt;\/operation&gt;\r\n\t&lt;\/binding&gt;\r\n\t&lt;service name=\"PersonServiceImplService\"&gt;\r\n\t\t&lt;port name=\"PersonServiceImplPort\" binding=\"tns:PersonServiceImplPortBinding\"&gt;\r\n\t\t\t&lt;soap:address location=\"http:\/\/127.0.0.1:10000\/personServer\" \/&gt;\r\n\t\t&lt;\/port&gt;\r\n\t&lt;\/service&gt;\r\n&lt;\/definitions&gt;\r\n<\/pre>\n<p>Notice the change here in <code>types<\/code> tag and <code>messages<\/code> tag. The <code>types<\/code> tag here says that it is importing schema from URL <code>http:\/\/127.0.0.1:10000\/personServer?xsd=1<\/code>.<\/p>\n<p><span style=\"text-decoration: underline\"><em>personService.xsd<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\n&lt;xs:schema xmlns:tns=\"http:\/\/jaxws.examples.javacodegeeks.com\/\"\r\n\txmlns:xs=\"http:\/\/www.w3.org\/2001\/XMLSchema\" version=\"1.0\"\r\n\ttargetNamespace=\"http:\/\/jaxws.examples.javacodegeeks.com\/\"&gt;\r\n\t&lt;xs:element name=\"getPerson\" type=\"tns:getPerson\" \/&gt;\r\n\t&lt;xs:element name=\"getPersonResponse\" type=\"tns:getPersonResponse\" \/&gt;\r\n\t&lt;xs:complexType name=\"getPerson\"&gt;\r\n\t\t&lt;xs:sequence&gt;\r\n\t\t\t&lt;xs:element name=\"arg0\" type=\"xs:int\" minOccurs=\"0\" \/&gt;\r\n\t\t&lt;\/xs:sequence&gt;\r\n\t&lt;\/xs:complexType&gt;\r\n\t&lt;xs:complexType name=\"getPersonResponse\"&gt;\r\n\t\t&lt;xs:sequence&gt;\r\n\t\t\t&lt;xs:element name=\"return\" type=\"tns:person\" minOccurs=\"0\" \/&gt;\r\n\t\t&lt;\/xs:sequence&gt;\r\n\t&lt;\/xs:complexType&gt;\r\n\t&lt;xs:complexType name=\"person\"&gt;\r\n\t\t&lt;xs:sequence&gt;\r\n\t\t\t&lt;xs:element name=\"id\" type=\"xs:int\" \/&gt;\r\n\t\t\t&lt;xs:element name=\"name\" type=\"xs:string\" minOccurs=\"0\" \/&gt;\r\n\t\t&lt;\/xs:sequence&gt;\r\n\t&lt;\/xs:complexType&gt;\r\n&lt;\/xs:schema&gt;\r\n<\/pre>\n<h2><a name=\"Client\"><\/a>5. Testing Web Service<\/h2>\n<p>In this section we shall implement web service client for the service implemented in section <a href=\"#DOCUMENT\">4<\/a> to test the same. On the same pattern web service implemented in section <a href=\"#WebServiceServer\">2<\/a> can be tested.<\/p>\n<p>We shall use Java provided <code>wsimport<\/code> utility that helps in generating this client support code using the WSDL document.<\/p>\n<p>Go to command prompt\/bash, browse to the location where <code>personService.wsdl<\/code> was saved, and enter following command:<\/p>\n<pre class=\"brush:bash\">$ wsimport -keep -p client personService.wsdl<\/pre>\n<p>This command shall generated following client support code:<\/p>\n<p><figure id=\"attachment_31893\" aria-describedby=\"caption-attachment-31893\" style=\"width: 507px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/wsimpoertGeneratedCode.jpg\" rel=\"attachment wp-att-31893\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/wsimpoertGeneratedCode.jpg\" alt=\"wsimport Generated Code\" width=\"507\" height=\"288\" class=\"size-full wp-image-31893\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/wsimpoertGeneratedCode.jpg 507w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/wsimpoertGeneratedCode-300x170.jpg 300w\" sizes=\"(max-width: 507px) 100vw, 507px\" \/><\/a><figcaption id=\"caption-attachment-31893\" class=\"wp-caption-text\">wsimport Generated Code<\/figcaption><\/figure><\/p>\n<p>Now we shall use this code in client project and call and check the web service.<\/p>\n<p><span style=\"text-decoration: underline\"><em>PersonServiceClient.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws.client;\r\n\r\nimport client.PersonServiceI;\r\nimport client.PersonServiceImplService;\r\n\r\npublic class PersonServiceClient {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tPersonServiceImplService service = new PersonServiceImplService();\r\n\t\tPersonServiceI pService = service.getPersonServiceImplPort();\r\n\t\t\r\n\t\tSystem.out.println(pService.getPerson(1).getName());\r\n\t\tSystem.out.println(pService.getPerson(2).getName());\r\n\t\tSystem.out.println(pService.getPerson(3).getName());\r\n\t\tSystem.out.println(pService.getPerson(4).getName());\r\n\t\tSystem.out.println(pService.getPerson(5).getName());\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>Output of this client program shall be:<\/p>\n<pre class=\"brush:bash\">\r\nA\r\nB\r\nC\r\nD\r\nE\r\n<\/pre>\n<h2><a name=\"Download\"><\/a>6. Download the source code<\/h2>\n<p>This example has 2 eclipse projects (server and client) for demonstrating example of JAX-WS Web Service.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <strong><a><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/JAX-WS_Web_Service_Example.zip\">JAX-WS Web Service Example<\/a><\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API&#8217;s provided by Java for implementing Web Service. Here, we shall start by learning what web services are, their architecture, followed by implementation of server and client. We shall also learn the different variants of XML Web Service and the WSDL file &hellip;<\/p>\n","protected":false},"author":75,"featured_media":1240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[461],"tags":[369,1264,1309,1311,1324,467,1320,1310,1281,254,1323],"class_list":["post-31636","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jws","tag-document","tag-jax-ws","tag-jax-ws-client","tag-jws-client","tag-rpc","tag-soap","tag-soap-architecture","tag-soap-client","tag-soapbinding","tag-web-services-2","tag-wsdl"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JAX-WS Web Service Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API&#039;s provided by Java for implementing Web Service. Here, we shall start\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JAX-WS Web Service Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API&#039;s provided by Java for implementing Web Service. Here, we shall start\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-18T13:00:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Saurabh Arora\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Saurabh Arora\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\"},\"author\":{\"name\":\"Saurabh Arora\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/5bf4e0274824642c44536b83ddbfaf6c\"},\"headline\":\"JAX-WS Web Service Example\",\"datePublished\":\"2016-01-18T13:00:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\"},\"wordCount\":1102,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"keywords\":[\"Document\",\"JAX-WS\",\"JAX-WS Client\",\"jws client\",\"RPC\",\"SOAP\",\"soap architecture\",\"SOAP Client\",\"soapbinding\",\"web services\",\"wsdl\"],\"articleSection\":[\"jws\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\",\"name\":\"JAX-WS Web Service Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"datePublished\":\"2016-01-18T13:00:48+00:00\",\"description\":\"In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API's provided by Java for implementing Web Service. Here, we shall start\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jws\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/jws\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"JAX-WS Web Service Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/5bf4e0274824642c44536b83ddbfaf6c\",\"name\":\"Saurabh Arora\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/11\/Saurabh-Arora-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/11\/Saurabh-Arora-96x96.jpg\",\"caption\":\"Saurabh Arora\"},\"description\":\"Saurabh graduated with an engineering degree in Information Technology from YMCA Institute of Engineering, India. He is SCJP, OCWCD certified and currently working as Technical Lead with one of the biggest service based firms and is involved in projects extensively using Java and JEE technologies. He has worked in E-Commerce, Banking and Telecom domain.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\",\"https:\/\/in.linkedin.com\/in\/saurabh-arora-78674b18\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/saurabh-arora\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JAX-WS Web Service Example - Java Code Geeks","description":"In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API's provided by Java for implementing Web Service. Here, we shall start","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/","og_locale":"en_US","og_type":"article","og_title":"JAX-WS Web Service Example - Java Code Geeks","og_description":"In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API's provided by Java for implementing Web Service. Here, we shall start","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-01-18T13:00:48+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Saurabh Arora","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Saurabh Arora","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/"},"author":{"name":"Saurabh Arora","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/5bf4e0274824642c44536b83ddbfaf6c"},"headline":"JAX-WS Web Service Example","datePublished":"2016-01-18T13:00:48+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/"},"wordCount":1102,"commentCount":3,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","keywords":["Document","JAX-WS","JAX-WS Client","jws client","RPC","SOAP","soap architecture","SOAP Client","soapbinding","web services","wsdl"],"articleSection":["jws"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/","name":"JAX-WS Web Service Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","datePublished":"2016-01-18T13:00:48+00:00","description":"In this example we shall learn implementing JAX-WS Web Service. JAX-WS are the API's provided by Java for implementing Web Service. Here, we shall start","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-web-service-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"jws","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/jws\/"},{"@type":"ListItem","position":5,"name":"JAX-WS Web Service Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/5bf4e0274824642c44536b83ddbfaf6c","name":"Saurabh Arora","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/11\/Saurabh-Arora-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/11\/Saurabh-Arora-96x96.jpg","caption":"Saurabh Arora"},"description":"Saurabh graduated with an engineering degree in Information Technology from YMCA Institute of Engineering, India. He is SCJP, OCWCD certified and currently working as Technical Lead with one of the biggest service based firms and is involved in projects extensively using Java and JEE technologies. He has worked in E-Commerce, Banking and Telecom domain.","sameAs":["http:\/\/www.javacodegeeks.com\/","https:\/\/in.linkedin.com\/in\/saurabh-arora-78674b18"],"url":"https:\/\/examples.javacodegeeks.com\/author\/saurabh-arora\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/31636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=31636"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/31636\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1240"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=31636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=31636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=31636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}