{"id":31301,"date":"2016-01-04T11:00:03","date_gmt":"2016-01-04T09:00:03","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=31301"},"modified":"2016-01-18T09:08:38","modified_gmt":"2016-01-18T07:08:38","slug":"jax-ws-client-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/","title":{"rendered":"JAX-WS Client Example"},"content":{"rendered":"<p>Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.<\/p>\n<p>Writing JAX-WS Client is easy. But we shall start our example by first creating a web service and then writing a client for the same.<\/p>\n<h2>1. Writing server for web service<\/h2>\n<h3>1.1 Writing Service Endpoint Interface<\/h3>\n<p>First step in writing web service server is to write the interface called Service Endpoint Interface that describes the methods that shall be exposed by web service.<\/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<h3>1.2 Writing Service Implementation Bean<\/h3>\n<p>Next step is to write Service Implementation Bean. This is the implementation of Service Endpoint Interface.<\/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<h3>1.3 Publishing the web service<\/h3>\n<p>And now comes the time to publish the web service. Here, we shall be using JAX-WS&#8217;s <code>Endpoint<\/code> API to publish the web service or in other words publish the endpoint.<\/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>In the above program, we are trying to publish the endpoint at URL: <code>http:\/\/127.0.0.1:10000\/calcServer<\/code>.<\/p>\n<h3><a name=\"1_4\"><\/a>1.4 Verify the web service<\/h3>\n<p>To verify if the web service has been properly published, we shall try to access the WSDL file from the browser. The URL shall be like: <code>http:\/\/127.0.0.1:10000\/calcServer?wsdl<\/code>.<\/p>\n<p>Upon hitting this URL we will be able to see the WSDL file which describes the web service.<\/p>\n<p>Let&#8217;s copy the content of this file into <code>calculator.wsdl<\/code>.<\/p>\n<p><span style=\"text-decoration: underline\"><em>calculator.wsdl<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:true\">\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=\"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;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;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=\"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\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&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=\"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\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&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<h2>2. Writing JAX-WS Client<\/h2>\n<h2>2.1 Generating client code from WSDL<\/h2>\n<p>The first step to writing JAX-WS Client is to generate client support code. Java provides <code>wsimport<\/code> utility that helps in generating this client support code using the WSDL document.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>On command prompt, enter following command at it will show the usage of this utility:<\/p>\n<p><code>$wsimport<\/code><\/p>\n<p>Now, let&#8217;s take the WSDL file that was saved in step <a href=\"#1_4\">1.4<\/a>, browse to the saved directory using command prompt, and execute the following command:<\/p>\n<p><code>$ wsimport -keep -p client calculator.wsdl<\/code><\/p>\n<p>Alternatively, we can also specify the URL of WSDL file in the wsimport command:<\/p>\n<p><code>$ wsimport -keep -p client http:\/\/127.0.0.1:10000\/calcServer?wsdl<\/code><\/p>\n<p>Output of this command shall be like:<\/p>\n<pre class=\"brush:bash\">\r\nparsing WSDL...\r\n\r\n\r\n\r\nGenerating code...\r\n\r\n\r\nCompiling code...\r\n<\/pre>\n<p>For the above example, it shall generate 2 java source files and 2 compiled files in the subdirectory client.<\/p>\n<p><figure id=\"attachment_31319\" aria-describedby=\"caption-attachment-31319\" style=\"width: 287px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/ClientCode.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/ClientCode.jpg\" alt=\"Generated Client Code\" width=\"287\" height=\"93\" class=\"size-full wp-image-31319\" \/><\/a><figcaption id=\"caption-attachment-31319\" class=\"wp-caption-text\">Generated Client Code<\/figcaption><\/figure><\/p>\n<p>Now, let&#8217;s breakdown the command that we used to generate client support code. Option <code>-p<\/code> specifies the java package in which generated files are to be placed, in this case it was client. <code>-keep<\/code> option is a flag that represents that generated files are to be kept. There are many other options which can be looked into by just writing <code>wsimport<\/code> in the command prompt as mentioned above.<\/p>\n<h3>2.2 Analyzing the client support code<\/h3>\n<p>Now let&#8217;s see the source files that <code>wsimport<\/code> has generated for us. After that we shall analyze these.<\/p>\n<p><code>wsimport<\/code> generated <code>CalculatorI<\/code>:<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalculatorI.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage client;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebParam;\r\nimport javax.jws.WebResult;\r\nimport javax.jws.WebService;\r\nimport javax.jws.soap.SOAPBinding;\r\nimport javax.xml.ws.Action;\r\n\r\n\r\n\/**\r\n * This class was generated by the JAX-WS RI.\r\n * JAX-WS RI 2.2.9-b130926.1035\r\n * Generated source version: 2.2\r\n * \r\n *\/\r\n@WebService(name = \"CalculatorI\", targetNamespace = \"http:\/\/jaxws.examples.javacodegeeks.com\/\")\r\n@SOAPBinding(style = SOAPBinding.Style.RPC)\r\npublic interface CalculatorI {\r\n\r\n\r\n    \/**\r\n     * \r\n     * @param arg1\r\n     * @param arg0\r\n     * @return\r\n     *     returns int\r\n     *\/\r\n    @WebMethod\r\n    @WebResult(partName = \"return\")\r\n    @Action(input = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/addRequest\", output = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/addResponse\")\r\n    public int add(\r\n        @WebParam(name = \"arg0\", partName = \"arg0\")\r\n        int arg0,\r\n        @WebParam(name = \"arg1\", partName = \"arg1\")\r\n        int arg1);\r\n\r\n    \/**\r\n     * \r\n     * @param arg1\r\n     * @param arg0\r\n     * @return\r\n     *     returns int\r\n     *\/\r\n    @WebMethod\r\n    @WebResult(partName = \"return\")\r\n    @Action(input = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/divideRequest\", output = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/divideResponse\")\r\n    public int divide(\r\n        @WebParam(name = \"arg0\", partName = \"arg0\")\r\n        int arg0,\r\n        @WebParam(name = \"arg1\", partName = \"arg1\")\r\n        int arg1);\r\n\r\n    \/**\r\n     * \r\n     * @param arg1\r\n     * @param arg0\r\n     * @return\r\n     *     returns int\r\n     *\/\r\n    @WebMethod\r\n    @WebResult(partName = \"return\")\r\n    @Action(input = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/multiplyRequest\", output = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/multiplyResponse\")\r\n    public int multiply(\r\n        @WebParam(name = \"arg0\", partName = \"arg0\")\r\n        int arg0,\r\n        @WebParam(name = \"arg1\", partName = \"arg1\")\r\n        int arg1);\r\n\r\n    \/**\r\n     * \r\n     * @param arg1\r\n     * @param arg0\r\n     * @return\r\n     *     returns int\r\n     *\/\r\n    @WebMethod\r\n    @WebResult(partName = \"return\")\r\n    @Action(input = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/subtractRequest\", output = \"http:\/\/jaxws.examples.javacodegeeks.com\/CalculatorI\/subtractResponse\")\r\n    public int subtract(\r\n        @WebParam(name = \"arg0\", partName = \"arg0\")\r\n        int arg0,\r\n        @WebParam(name = \"arg1\", partName = \"arg1\")\r\n        int arg1);\r\n\r\n}\r\n<\/pre>\n<p><code>wsimport<\/code> generated <code>CalculatorImplService<\/code>:<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalculatorImplService.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage client;\r\n\r\nimport java.net.MalformedURLException;\r\nimport java.net.URL;\r\nimport javax.xml.namespace.QName;\r\nimport javax.xml.ws.Service;\r\nimport javax.xml.ws.WebEndpoint;\r\nimport javax.xml.ws.WebServiceClient;\r\nimport javax.xml.ws.WebServiceException;\r\nimport javax.xml.ws.WebServiceFeature;\r\n\r\n\r\n\/**\r\n * This class was generated by the JAX-WS RI.\r\n * JAX-WS RI 2.2.9-b130926.1035\r\n * Generated source version: 2.2\r\n * \r\n *\/\r\n@WebServiceClient(name = \"CalculatorImplService\", targetNamespace = \"http:\/\/jaxws.examples.javacodegeeks.com\/\", wsdlLocation = \"file:\/Users\/saurabharora123\/Downloads\/calculator.wsdl\")\r\npublic class CalculatorImplService\r\n    extends Service\r\n{\r\n\r\n    private final static URL CALCULATORIMPLSERVICE_WSDL_LOCATION;\r\n    private final static WebServiceException CALCULATORIMPLSERVICE_EXCEPTION;\r\n    private final static QName CALCULATORIMPLSERVICE_QNAME = new QName(\"http:\/\/jaxws.examples.javacodegeeks.com\/\", \"CalculatorImplService\");\r\n\r\n    static {\r\n        URL url = null;\r\n        WebServiceException e = null;\r\n        try {\r\n            url = new URL(\"file:\/Users\/saurabharora123\/Downloads\/calculator.wsdl\");\r\n        } catch (MalformedURLException ex) {\r\n            e = new WebServiceException(ex);\r\n        }\r\n        CALCULATORIMPLSERVICE_WSDL_LOCATION = url;\r\n        CALCULATORIMPLSERVICE_EXCEPTION = e;\r\n    }\r\n\r\n    public CalculatorImplService() {\r\n        super(__getWsdlLocation(), CALCULATORIMPLSERVICE_QNAME);\r\n    }\r\n\r\n    public CalculatorImplService(WebServiceFeature... features) {\r\n        super(__getWsdlLocation(), CALCULATORIMPLSERVICE_QNAME, features);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation) {\r\n        super(wsdlLocation, CALCULATORIMPLSERVICE_QNAME);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation, WebServiceFeature... features) {\r\n        super(wsdlLocation, CALCULATORIMPLSERVICE_QNAME, features);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation, QName serviceName) {\r\n        super(wsdlLocation, serviceName);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {\r\n        super(wsdlLocation, serviceName, features);\r\n    }\r\n\r\n    \/**\r\n     * \r\n     * @return\r\n     *     returns CalculatorI\r\n     *\/\r\n    @WebEndpoint(name = \"CalculatorImplPort\")\r\n    public CalculatorI getCalculatorImplPort() {\r\n        return super.getPort(new QName(\"http:\/\/jaxws.examples.javacodegeeks.com\/\", \"CalculatorImplPort\"), CalculatorI.class);\r\n    }\r\n\r\n    \/**\r\n     * \r\n     * @param features\r\n     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features<\/code> parameter will have their default values.\r\n     * @return\r\n     *     returns CalculatorI\r\n     *\/\r\n    @WebEndpoint(name = \"CalculatorImplPort\")\r\n    public CalculatorI getCalculatorImplPort(WebServiceFeature... features) {\r\n        return super.getPort(new QName(\"http:\/\/jaxws.examples.javacodegeeks.com\/\", \"CalculatorImplPort\"), CalculatorI.class, features);\r\n    }\r\n\r\n    private static URL __getWsdlLocation() {\r\n        if (CALCULATORIMPLSERVICE_EXCEPTION!= null) {\r\n            throw CALCULATORIMPLSERVICE_EXCEPTION;\r\n        }\r\n        return CALCULATORIMPLSERVICE_WSDL_LOCATION;\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Points to be noted here:<\/p>\n<ol type=\"1\">\n<li><code>wsimport<\/code> generated <code>CalculatorI<\/code> contains the same methods as the original <code>CalculatorI<\/code> at server side had.<\/li>\n<li><code>CalculatorImplService<\/code> has a no-argument constructor that shall construct the <code>Service<\/code> object.<\/li>\n<li><code>CalculatorImplService<\/code> has a method <code>getCalculatorImplPort()<\/code> that returns instance of <code>CalculatorI<\/code> on which service methods shall be invoked.<\/li>\n<\/ol>\n<h3>2.3 Invoking the web service<\/h3>\n<p>The last step to this tutorial is invoking the web service. To do this let&#8217;s first create a new java project and then copy the client support code into it.<\/p>\n<p>You might want to change line#32 in <code>CalculatorImplService<\/code> that mentions the URL to the HTTP URL instead of file path if you need it. In this case the updated <code>CalculatorImplService<\/code> shall be like:<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalculatorImplService.java<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight:[32]\">\r\npackage client;\r\n\r\nimport java.net.MalformedURLException;\r\nimport java.net.URL;\r\nimport javax.xml.namespace.QName;\r\nimport javax.xml.ws.Service;\r\nimport javax.xml.ws.WebEndpoint;\r\nimport javax.xml.ws.WebServiceClient;\r\nimport javax.xml.ws.WebServiceException;\r\nimport javax.xml.ws.WebServiceFeature;\r\n\r\n\r\n\/**\r\n * This class was generated by the JAX-WS RI.\r\n * JAX-WS RI 2.2.9-b130926.1035\r\n * Generated source version: 2.2\r\n * \r\n *\/\r\n@WebServiceClient(name = \"CalculatorImplService\", targetNamespace = \"http:\/\/jaxws.examples.javacodegeeks.com\/\", wsdlLocation = \"file:\/Users\/saurabharora123\/Downloads\/calculator.wsdl\")\r\npublic class CalculatorImplService\r\n    extends Service\r\n{\r\n\r\n    private final static URL CALCULATORIMPLSERVICE_WSDL_LOCATION;\r\n    private final static WebServiceException CALCULATORIMPLSERVICE_EXCEPTION;\r\n    private final static QName CALCULATORIMPLSERVICE_QNAME = new QName(\"http:\/\/jaxws.examples.javacodegeeks.com\/\", \"CalculatorImplService\");\r\n\r\n    static {\r\n        URL url = null;\r\n        WebServiceException e = null;\r\n        try {\r\n            url = new URL(\"http:\/\/127.0.0.1:10000\/calcServer?wsdl\");\r\n        } catch (MalformedURLException ex) {\r\n            e = new WebServiceException(ex);\r\n        }\r\n        CALCULATORIMPLSERVICE_WSDL_LOCATION = url;\r\n        CALCULATORIMPLSERVICE_EXCEPTION = e;\r\n    }\r\n\r\n    public CalculatorImplService() {\r\n        super(__getWsdlLocation(), CALCULATORIMPLSERVICE_QNAME);\r\n    }\r\n\r\n    public CalculatorImplService(WebServiceFeature... features) {\r\n        super(__getWsdlLocation(), CALCULATORIMPLSERVICE_QNAME, features);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation) {\r\n        super(wsdlLocation, CALCULATORIMPLSERVICE_QNAME);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation, WebServiceFeature... features) {\r\n        super(wsdlLocation, CALCULATORIMPLSERVICE_QNAME, features);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation, QName serviceName) {\r\n        super(wsdlLocation, serviceName);\r\n    }\r\n\r\n    public CalculatorImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {\r\n        super(wsdlLocation, serviceName, features);\r\n    }\r\n\r\n    \/**\r\n     * \r\n     * @return\r\n     *     returns CalculatorI\r\n     *\/\r\n    @WebEndpoint(name = \"CalculatorImplPort\")\r\n    public CalculatorI getCalculatorImplPort() {\r\n        return super.getPort(new QName(\"http:\/\/jaxws.examples.javacodegeeks.com\/\", \"CalculatorImplPort\"), CalculatorI.class);\r\n    }\r\n\r\n    \/**\r\n     * \r\n     * @param features\r\n     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features<\/code> parameter will have their default values.\r\n     * @return\r\n     *     returns CalculatorI\r\n     *\/\r\n    @WebEndpoint(name = \"CalculatorImplPort\")\r\n    public CalculatorI getCalculatorImplPort(WebServiceFeature... features) {\r\n        return super.getPort(new QName(\"http:\/\/jaxws.examples.javacodegeeks.com\/\", \"CalculatorImplPort\"), CalculatorI.class, features);\r\n    }\r\n\r\n    private static URL __getWsdlLocation() {\r\n        if (CALCULATORIMPLSERVICE_EXCEPTION!= null) {\r\n            throw CALCULATORIMPLSERVICE_EXCEPTION;\r\n        }\r\n        return CALCULATORIMPLSERVICE_WSDL_LOCATION;\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Now we shall write java client that uses <code>wsimport<\/code> generated artifacts to access the web service.<\/p>\n<p><span style=\"text-decoration: underline\"><em>CalculatorClient.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.examples.jaxws.client;\r\n\r\nimport client.CalculatorI;\r\nimport client.CalculatorImplService;\r\n\r\npublic class CalculatorClient {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tCalculatorImplService service = new CalculatorImplService();\r\n\t\tCalculatorI calc = service.getCalculatorImplPort();\r\n\t\t\r\n\t\tSystem.out.println(calc.add(1, 2));\r\n\t\tSystem.out.println(calc.subtract(2, 2));\r\n\t\tSystem.out.println(calc.multiply(2, 4));\r\n\t\tSystem.out.println(calc.divide(6, 3));\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>On running this program, the output shall be like:<\/p>\n<pre class=\"brush:bash\">\r\n3\r\n0\r\n8\r\n2\r\n<\/pre>\n<h2>3. Directory structure of this example<\/h2>\n<h3>3.1 Directory structure of web service server project<\/h3>\n<p>The directory structure of web service server project in eclipse shall look like:<\/p>\n<p><figure id=\"attachment_31317\" aria-describedby=\"caption-attachment-31317\" style=\"width: 368px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceServerDirectoryStructure.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceServerDirectoryStructure.jpg\" alt=\"Web Service Server Directory Structure\" width=\"368\" height=\"241\" class=\"size-full wp-image-31317\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceServerDirectoryStructure.jpg 368w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceServerDirectoryStructure-300x196.jpg 300w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/a><figcaption id=\"caption-attachment-31317\" class=\"wp-caption-text\">Web Service Server Directory Structure<\/figcaption><\/figure><\/p>\n<h3>3.2 Directory structure of web service client project<\/h3>\n<p>The directory structure of web service client project in eclipse shall look like:<\/p>\n<p><figure id=\"attachment_31318\" aria-describedby=\"caption-attachment-31318\" style=\"width: 379px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceClientDirectoryStructure.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceClientDirectoryStructure.jpg\" alt=\"Web Service Client Directory Structure\" width=\"379\" height=\"323\" class=\"size-full wp-image-31318\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceClientDirectoryStructure.jpg 379w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/WebServiceClientDirectoryStructure-300x256.jpg 300w\" sizes=\"(max-width: 379px) 100vw, 379px\" \/><\/a><figcaption id=\"caption-attachment-31318\" class=\"wp-caption-text\">Web Service Client Directory Structure<\/figcaption><\/figure><\/p>\n<h2>4. Download the source code<\/h2>\n<p>This example has 2 eclipse projects for demonstrating example of JAX-WS Client.<\/p>\n<p>Download the Eclipse project here:<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <strong><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/JAX-WSClientExample.zip\">JAX-WS Client Example<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service. Writing JAX-WS Client is easy. But we shall start our example by first creating a web service and then writing a client for the &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":[1264,1309,1311,467,1310,1312],"class_list":["post-31301","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jws","tag-jax-ws","tag-jax-ws-client","tag-jws-client","tag-soap","tag-soap-client","tag-wsimport"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JAX-WS Client Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.\" \/>\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-client-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JAX-WS Client Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-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-04T09:00:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-01-18T07:08:38+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=\"12 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-client-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/\"},\"author\":{\"name\":\"Saurabh Arora\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/5bf4e0274824642c44536b83ddbfaf6c\"},\"headline\":\"JAX-WS Client Example\",\"datePublished\":\"2016-01-04T09:00:03+00:00\",\"dateModified\":\"2016-01-18T07:08:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/\"},\"wordCount\":684,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"keywords\":[\"JAX-WS\",\"JAX-WS Client\",\"jws client\",\"SOAP\",\"SOAP Client\",\"wsimport\"],\"articleSection\":[\"jws\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/\",\"name\":\"JAX-WS Client Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg\",\"datePublished\":\"2016-01-04T09:00:03+00:00\",\"dateModified\":\"2016-01-18T07:08:38+00:00\",\"description\":\"Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-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-client-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 Client 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 Client Example - Java Code Geeks","description":"Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.","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-client-example\/","og_locale":"en_US","og_type":"article","og_title":"JAX-WS Client Example - Java Code Geeks","og_description":"Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-01-04T09:00:03+00:00","article_modified_time":"2016-01-18T07:08:38+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":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/"},"author":{"name":"Saurabh Arora","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/5bf4e0274824642c44536b83ddbfaf6c"},"headline":"JAX-WS Client Example","datePublished":"2016-01-04T09:00:03+00:00","dateModified":"2016-01-18T07:08:38+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/"},"wordCount":684,"commentCount":5,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","keywords":["JAX-WS","JAX-WS Client","jws client","SOAP","SOAP Client","wsimport"],"articleSection":["jws"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/","name":"JAX-WS Client Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/enterprise-java-logo.jpg","datePublished":"2016-01-04T09:00:03+00:00","dateModified":"2016-01-18T07:08:38+00:00","description":"Hosting a web service is of no use until it becomes usable by a client. In this example we shall learn how to write JAX-WS client for a SOAP web service.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/jws\/jax-ws-client-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-client-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 Client 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\/31301","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=31301"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/31301\/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=31301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=31301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=31301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}