Package
CN. MRZ. myws;
Import javax. JWS. webmethod;
Import javax. JWS. webparam;
Import javax. JWS. webresult;
Import javax. JWS. WebService;
Import javax. xml. ws. endpoint;
@ WebService (name = "My Service Interface Name", portname = "my service port name", servicename = "my service name", targetnamespace = "zhanghao.com ", wsdllocation = "")
Public class Hello { @ Webmethod (operationname = "greetings ")
Public
@ Webresult (name = "which ")
String sayhi (
@ Webparam (name = "name ")
String name)
{
System. Out. println ("welcome" + name
+ "Call sayhi ()");
Return "hi" + name;
}
Public static void main (string [] ARGs ){
Endpoint. Publish ("http: // localhost: 7777/one", new
Hello ());
}
}
Http: // localhost: 7777/one? 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 ="Zhanghao.com"Xmlns: XSD ="Http://www.w3.org/2001/XMLSchema"Xmlns ="Http://schemas.xmlsoap.org/wsdl/"
Targetnamespace ="Zhanghao.com"Name ="My service name">-<Types>-<XSD: schema>
<XSD: Import namespace ="Zhanghao.com"Schemalocation ="Http: // localhost: 7777/one? XSD = 1"
/>
</XSD: schema>
</Types>-<Message
Name ="Greetings">
<Part name ="Parameters"Element ="TNS: Greetings"/>
</Message>-<Message
Name ="Greeting response">
<Part name ="Parameters"Element ="TNS: greeting response"/>
</Message>-<Porttype
Name ="My service interface Name">-<Operation
Name ="Greetings">
<Input message ="TNS: Greetings"/>
<Output Message ="TNS: greeting response"/>
</Operation>
</Porttype>-<Binding
Name ="My service port name binding"Type ="TNS: My Service Interface Name">
<Soap: Binding transport ="Http://schemas.xmlsoap.org/soap/http"
Style ="Document"/>-<Operation
Name ="Greetings">
<Soap: Operation soapaction = ""
/>-<Input>
<Soap: Body use ="Literal"
/>
</Input>-<Output>
<Soap: Body use ="Literal"
/>
</Output>
</Operation>
</Binding>-<Service
Name ="My service name">-<Port
Name ="My service port name"Binding ="TNS: My service port name binding">
<Soap: address location ="Http: // localhost: 7777/One"
/>
</Port>
</Service>
</Definitions> Http: // localhost: 7777/one? XSD = 1
<? 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 ="Zhanghao.com"Xmlns: xs ="Http://www.w3.org/2001/XMLSchema"Version ="1.0"Targetnamespace ="Zhanghao.com">
<Xs: element name ="Greetings"Type ="TNS: Greetings"/>
<Xs: element name ="Greeting response"Type ="TNS: greeting response"/>-<Xs: complextype
Name ="Greetings">-<Xs: sequence>
<Xs: element name ="Name"Type ="Xs: String"Minoccurs ="0"/>
</Xs: sequence>
</Xs: complextype>-<Xs: complextype
Name ="Greeting response">-<Xs: sequence>
<Xs: element name ="Which"Type ="Xs: String"Minoccurs ="0"/>
</Xs: sequence>
</Xs: complextype>
</Xs: schema>