是否可以使用一个端点运行两个ws实现?

时间:2011-11-09 11:52:30

标签: java web-services jax-ws endpoints

我有两个共享一些命名空间的webservices实现(使用相同的对象 - 示例中的对象C)。 我想发布它如此

1)客户端将共享生成的对象(相同的对象C stub)

2)我可以在一个端口上运行booth webservices,只需更改url就可以访问它们,如bellow

http://localhost:6690/WS/A?wsdl
http://localhost:6690/WS/B?wsdl

package a.wsdl.xxx.com;
@WebService(targetNamespace = "a.wsdl.xxx.com", serviceName = "A", name = "A")
public class A{
    @WebMethod
    public C a(){...}
}

// --------------------------------------------- -------------------

package a.wsdl.xxx.com;   
@WebService(targetNamespace = "b.wsdl.xxx.com", serviceName = "B", name = "B")
public class B{
    @WebMethod
    public C b(){...}
}

// --------------------------------------------- -------------------

package xxx.com; 
public class C{
 String s; 
 ....
} 

2 个答案:

答案 0 :(得分:1)

是的,我刚创建了两个war文件greeting1.war和greeting2.war。它们中的每一个都实现了一个hello-world接口,如下所示,只有类名称不同Greeting1Greeting2。然后我把它们都部署到了jboss。两者都可以通过http://localhost:8080/greeting1?wsdlhttp://localhost:8080/greeting2?wsdl

访问
package my.webservice;

import javax.jws.WebService;
import javax.jws.WebMethod;

@WebService
public class Greeting1 {
   @WebMethod
   public String greetClient(String user)
   {
      return "hello " + user;
   }
}

答案 1 :(得分:-1)

两个或多个应用程序无法侦听同一端口。

相关问题