Last active
September 30, 2016 07:34
-
-
Save riversun/453c6352130227de9391978f51d41bf1 to your computer and use it in GitHub Desktop.
[SOF]How create JAX-WS webservices server and client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>wsimport -keep http://localhost:8080/hello?wsdl | |
keep means generate both .class files and .java files | |
How to generate WSDL with XSD. | |
>cd <ProjectFolder>/bin | |
>wsgen -cp . test.HelloImpl -wsdl -inlineSchemas | |
HelloService.wsdl will be created. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import javax.jws.WebMethod; | |
import javax.jws.WebParam; | |
import javax.jws.WebParam.Mode; | |
import javax.jws.WebService; | |
/** | |
* Service Logic Class | |
* | |
* @author Tom Misawa ([email protected]) | |
* | |
*/ | |
@WebService(serviceName = "HelloService", targetNamespace = "http://example.com/",wsdlLocation="HelloService.wsdl") | |
public class HelloImpl { | |
@WebMethod | |
public String sayHello(@WebParam(name = "name", mode = Mode.IN) String name) { | |
return "Hello, " + name + "!"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import javax.jws.WebMethod; | |
import javax.jws.WebParam; | |
import javax.jws.WebParam.Mode; | |
import javax.jws.WebService; | |
/** | |
* Service Logic Class | |
* | |
* @author Tom Misawa ([email protected]) | |
* | |
*/ | |
@WebService(serviceName = "HelloService", targetNamespace = "http://example.com/") | |
public class HelloImpl { | |
@WebMethod | |
public String sayHello(@WebParam(name = "name", mode = Mode.IN) String name) { | |
return "Hello, " + name + "!"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import javax.xml.ws.Endpoint; | |
/** | |
* | |
* Launch service with standalone webserver | |
* | |
* @author Tom Misawa ([email protected]) | |
*/ | |
public class HelloServiceLauncher { | |
public static void main(String[] args) { | |
Endpoint.publish("http://localhost:8080/hello", new HelloImpl()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment