tst*_*ter 12 java axis soap web-services
好的,我正在开发一个程序,它将被部署到许多机器上(Windows,Linux,AIX,z/Linux,openVMS等).我希望该应用程序包含SOAP Web服务,但我不想捆绑tomcat或为服务运行单独的服务(我希望它们与应用程序的其余部分在同一进程中).
基本上我正在寻找的是我可以定义一个类(比如说WebServices).我也可以编写WSDL或任何其他类型的服务描述.我想要这样的东西:
SOAPServer server = makeMeASoapServer();
//do config on the server
server.add(new WebService(...));
server.listen(port);
Run Code Online (Sandbox Code Playgroud)
显然名称和参数会有所不同.
我一直在看Axis,它似乎提供了这个,但我不知道我需要使用哪些类.我是否因为想要这种行为而疯狂?我不敢相信更多的人不会这样做,我一直在.NET客户端中使用嵌入式Web服务.
nos*_*nos 23
似乎jdk 6.0已经附带了jax-ws实现,并且你可以嵌入一个小服务器.我没有弄清楚所有的碎片,但这是一个开始:
mkdir -p helloservice/endpoint/
Run Code Online (Sandbox Code Playgroud)
helloservice/endpoint/Hello.java:
package helloservice.endpoint;
import javax.jws.WebService;
@WebService()
public class Hello {
private String message = new String("Hello, ");
public void Hello() {}
public String sayHello(String name) {
return message + name + ".";
}
}
Run Code Online (Sandbox Code Playgroud)
HelloService的/端点/ Server.java:
package helloservice.endpoint;
import javax.xml.ws.Endpoint;
public class Server {
protected Server() throws Exception {
System.out.println("Starting Server");
Object implementor = new Hello();
String address = "http://localhost:9000/SoapContext/SoapPort";
Endpoint.publish(address, implementor);
}
public static void main(String args[]) throws Exception {
new Server();
System.out.println("Server ready...");
Thread.sleep(5 * 60 * 1000);
System.out.println("Server exiting");
System.exit(0);
}
}
Run Code Online (Sandbox Code Playgroud)
构建东西:
mkdir build
javac -d build helloservice/endpoint/*java
$JAVA_HOME/wsgen -d build -s build -classpath . helloservice.endpoint.Hello
Run Code Online (Sandbox Code Playgroud)
运行东西:
java -cp build helloservice.endpoint.Server
Run Code Online (Sandbox Code Playgroud)
现在在http:// localhost:9000/SoapContext/SoapPort上运行的东西.你可以在http:// localhost:9000/SoapContext/SoapPort?WSDL上获取wsdl
还没有找到一个客户端..
| 归档时间: |
|
| 查看次数: |
14053 次 |
| 最近记录: |