用于Java的进程内SOAP服务服务器 [英] In-process SOAP service server for Java

查看:133
本文介绍了用于Java的进程内SOAP服务服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我正在开发一个程序,它将被部署到许多机器上(Windows,Linux,AIX,z / Linux,openVMS等)。我希望该应用程序包含SOAP Web服务,但我不想捆绑tomcat或为服务运行单独的服务(我希望它们与应用程序的其余部分在同一进程中)。

OK, I am developing a program which will be deployed to lots of machines (Windows, Linux, AIX, z/Linux, openVMS, etc.). I want that application to contain a SOAP web service, but I don't want to bundle tomcat or run a separate service for the services (I want them in the same process as the rest of the application).

基本上我正在寻找的是我可以定义一个类(比如 WebServices )。我也可以编写WSDL或任何其他类型的服务描述。我想要这样的东西:

Basically what I'm looking for is something where I can define a class (say WebServices). I'm OK with writing WSDL or any other kind of service description as well. The I want something like this:

SOAPServer server = makeMeASoapServer();
//do config on the server
server.add(new WebService(...));
server.listen(port);

显然,名称和参数会有所不同。

Obviously the names and parameters will be different.

我一直在看Axis,它似乎提供了这个,但我不知道我需要使用哪些类。我是否因为想要这种行为而疯狂?我不敢相信更多的人不会这样做,我一直在.NET客户端中使用嵌入式Web服务。

I've been looking at Axis, and it seems like it provides this, but I don't know what classes I need to use. Am I crazy in wanting this kind of behavior? I can't believe more people aren't looking for this, I do this all the time with embedded web services within .NET clients.

推荐答案

似乎jdk 6.0已经附带了jax-ws实现,还有一个可以嵌入的小服务器。
我没有想出所有的部分,但这是一个开始:

Seems jdk 6.0 already comes with a jax-ws implementation, and a little server you can embed. I havn't figured out all the pieces but here's a start:

mkdir -p helloservice/endpoint/

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 + ".";
  }
}

helloservice / endpoint / 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);
    }
}

构建东西:

mkdir build
javac -d build helloservice/endpoint/*java
$JAVA_HOME/wsgen -d build -s build -classpath .  helloservice.endpoint.Hello

运行东西:

java -cp  build helloservice.endpoint.Server

现在在 http:// localhost:9000 / SoapContext / SoapPort 上运行的某些事情。
您可以通过 http:// localhost:9000 / SoapContext / SoapPort?WSDL

Somethings running on http://localhost:9000/SoapContext/SoapPort now. You can get the wsdl on http://localhost:9000/SoapContext/SoapPort?WSDL

还没有找到一个客户..

Havn't gotten around to making a client yet..

这篇关于用于Java的进程内SOAP服务服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆