package webservice;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class TestWebservice {
public String getValue(String name){
return "my name is :"+name;
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:9001/test/TestWebservice", new TestWebservice());
System.out.println("webservice success!");
}
}
直接把代码copy到myeclipse运行就可以了,启动后,在浏览器访问:
http://localhost:9001/test/TestWebservice?wsdl
效果如下
<definitions targetNamespace="http://webservice/" name="TestWebserviceService"><types><xsd:schema>
<xsd:import namespace="http://webservice/" schemaLocation="http://localhost:9001/test/TestWebservice?xsd=1"/>
</xsd:schema></types><message name="getValue"><part name="parameters" element="tns:getValue"/></message>
<message name="getValueResponse"><part name="parameters" element="tns:getValueResponse"/></message>
<portType name="TestWebservice"><operation name="getValue"><input message="tns:getValue"/><output message="tns:getValueResponse"/>
</operation></portType><binding name="TestWebservicePortBinding" type="tns:TestWebservice">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getValue"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/>
</output></operation></binding><service name="TestWebserviceService"><port name="TestWebservicePort" binding="tns:TestWebservicePortBinding">
<soap:address location="http://localhost:9001/test/TestWebservice"/></port></service></definitions>