ws

Simple JAX-WS service

  • SimpleWsService.java
  • pom.xml
  • wsdl

http://localhost:9080/jax_ws_simple_service/SimpleWsServiceService?wsdl

SimpleWsService.java

package com.training.ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public class SimpleWsService {

    @WebMethod(
            action = "getServiceNameAction", 
            operationName = "getServiceName", 
            exclude = false)
    public String getServiceName() {
        return "SimpleWsService";
    }

    @WebMethod(
            action = "helloAction", 
            operationName = "hello", 
            exclude = false)
    public String hello(@WebParam(name = "nameParam") String name) {
        return "Hello: " + name;
    }

}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.training.rs</groupId>
    <artifactId>jax_ws_simple_service</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>

wsdl

<wsdl:definitions name="SimpleWsServiceService" targetNamespace="http://ws.training.com/"><wsdl:types><xs:schema elementFormDefault="unqualified" targetNamespace="http://ws.training.com/" version="1.0"><xs:element name="getServiceName" type="tns:getServiceName"/><xs:element name="getServiceNameResponse" type="tns:getServiceNameResponse"/><xs:element name="hello" type="tns:hello"/><xs:element name="helloResponse" type="tns:helloResponse"/><xs:complexType name="hello"><xs:sequence><xs:element minOccurs="0" name="nameParam" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="helloResponse"><xs:sequence><xs:element minOccurs="0" name="return" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="getServiceName"><xs:sequence/></xs:complexType><xs:complexType name="getServiceNameResponse"><xs:sequence><xs:element minOccurs="0" name="return" type="xs:string"/></xs:sequence></xs:complexType></xs:schema></wsdl:types><wsdl:message name="getServiceNameResponse"><wsdl:part element="tns:getServiceNameResponse" name="parameters">
    </wsdl:part></wsdl:message><wsdl:message name="getServiceName"><wsdl:part element="tns:getServiceName" name="parameters">
    </wsdl:part></wsdl:message><wsdl:message name="hello"><wsdl:part element="tns:hello" name="parameters">
    </wsdl:part></wsdl:message><wsdl:message name="helloResponse"><wsdl:part element="tns:helloResponse" name="parameters">
    </wsdl:part></wsdl:message><wsdl:portType name="SimpleWsService"><wsdl:operation name="hello"><wsdl:input message="tns:hello" name="hello">
    </wsdl:input><wsdl:output message="tns:helloResponse" name="helloResponse">
    </wsdl:output></wsdl:operation><wsdl:operation name="getServiceName"><wsdl:input message="tns:getServiceName" name="getServiceName">
    </wsdl:input><wsdl:output message="tns:getServiceNameResponse" name="getServiceNameResponse">
    </wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="SimpleWsServiceServiceSoapBinding" type="tns:SimpleWsService"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="getServiceName"><soap:operation soapAction="getServiceNameAction" style="document"/><wsdl:input name="getServiceName"><soap:body use="literal"/></wsdl:input><wsdl:output name="getServiceNameResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="hello"><soap:operation soapAction="helloAction" style="document"/><wsdl:input name="hello"><soap:body use="literal"/></wsdl:input><wsdl:output name="helloResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="SimpleWsServiceService"><wsdl:port binding="tns:SimpleWsServiceServiceSoapBinding" name="SimpleWsServicePort"><soap:address location="http://localhost:9080/jax_ws_simple_service/SimpleWsServiceService"/></wsdl:port></wsdl:service></wsdl:definitions>