1

服务器:JBoss 7.1 Java:7(JAX-WS 版本:2.2.4-b01)

例1:

@Name("CustomerServices")
@Stateless
@WebService
public class CustomerServices{ ... }

例 2:

@Name("CustomerServices")
@Stateless
@WebService(servicename="CustomerServices")
public class CustomerServices { ... }

当 JBOSS 通过 JAX-WS 生成 wsdl 文件时,wsdl 看起来像:

例1:

<wsdl:definitions>
...
    <wsdl:service name="CustomerServicesService">
        <wsdl:port binding="tns:CustomerServicesServiceSoapBinding"> 
            <soap:address location="<host>:<port>/<ejb-context>/CustomerServices"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

例 2:

<wsdl:definitions>
...
    <wsdl:service name="CustomerServices">
        <wsdl:port binding="tns:CustomerServicesServiceSoapBinding"> 
            <soap:address location="<host>:<port>/<ejb-context>/CustomerServicesService/CustomerServicesService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

所以我的问题是,如何获得这个输出?

<wsdl:definitions>
...
  <wsdl:service name="CustomerServices">
    <wsdl:port binding="tns:CustomerServicesServiceSoapBinding"> 
    <soap:address location="<host>:<port>/<ejb-context>/CustomerServices"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

服务名称必须是CustomerServices而不是 CustomerServicesService,并且地址位置必须是../CustomerServices

谢谢。

4

1 回答 1

2

尝试:

@WebContext(contextRoot = "<ejb-context>", urlPattern = "/CustomerServices")

您还可以使用以下方法将 portType 设置为其他内容(即:<wsdl:portType name="MyCustomerServices">这将是生成客户端时端口接口的名称):

@WebService(name = "MyCustomerServices", serviceName = "CustomerServices")
于 2013-11-05T19:20:00.313 回答