This example creates a simple webservice using JAX-WS
Use the URL in the above wsdl under SchemaLocation http://localhost:8181/message?xsd=1
Use SoapUI or Webservices Explorer in eclipse, post the Wsdl link and you should be able to use your first webservice
Message.java
package edu.demo.ws;
importjavax.jws.WebMethod;
importjavax.jws.WebService;
@WebService
public class Message {
@WebMethod
public String getMessage(String text) {
return "Message " + text;
}
}
Main.java
package edu.demo.ws;
importjavax.xml.ws.Endpoint;
public class Main {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8181/message", new Message());
}
}
Run the Main.java as Java Application and in the browser open the url http://localhost:8181/message?wsdl
<?xml version="1.0" encoding="UTF-8" ?>
- <!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <!--
Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.demo.edu/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.demo.edu/" name="MessageService">
<xsd:import namespace="http://ws.demo.edu/" schemaLocation="http://localhost:8181/message?xsd=1" />
</xsd:schema>
</types>
<part name="parameters" element="tns:getMessage" />
</message>
<part name="parameters" element="tns:getMessageResponse" />
</message>
<input message="tns:getMessage" />
<output message="tns:getMessageResponse" />
</operation>
</portType>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<soap:operation soapAction="" />
<soap:body use="literal" />
</input>
<soap:body use="literal" />
</output>
</operation>
</binding>
<soap:address location="http://localhost:8181/message" />
</port>
</service>
</definitions>
<?xml version="1.0" encoding="UTF-8" ?>
- <!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <xs:schema xmlns:tns="http://ws.demo.edu/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://ws.demo.edu/">
<xs:element name="getMessage" type="tns:getMessage" />
<xs:element name="getMessageResponse" type="tns:getMessageResponse" />
<xs:element name="arg0" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:element name="return" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Use SoapUI or Webservices Explorer in eclipse, post the Wsdl link and you should be able to use your first webservice