2011-01-20 76 views
2

我正在開發一個JAX-WS WebService,我目前需要定義一個自定義的Binding名稱,因爲它被定義爲帶有「綁定」的端口名稱。在JAX-WS中定義綁定名稱

例如: - 如果端口名字是MyJAXService綁定名稱將是MyJAXServiceBinding默認。我想要的是綁定名稱是MyJAXService

我的Web服務定義了@WebService註釋如下

@WebService(serviceName = "MyJAXService", portName = "MyJAXService", endpointInterface = "com.test.MyJAXService", targetNamespace = "http://test.local/") 

回答

4

我假設你正在使用的Java到WSDL方法所以,你想生成您的工件的WSDL。

我通常使用的另一種方法,WSDL到Java,並且對於像WSDL:

<?xml version="1.0" encoding="utf-8"?> 
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="http://mynamespace" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://mynamespace"> 
    ... 
    <portType name="MySoapBinding"> 
    <operation name="MyOperation"> 
     ... 
    </operation> 
    </portType> 
    <binding name="MySoapBinding" type="ns:MySoapBinding"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="MyOperation"> 
     ... 
    </operation> 
    </binding> 
    <service name="MyService"> 
    <port name="MySoapBinding" binding="ns:MySoapBinding"> 
     <soap:address location="http://localhost:8080/MyService"/> 
    </port> 
    </service> 
</definitions> 

產生的僞影,接口:

@WebService(name = "MySoapBinding", targetNamespace = "http://mynamespace") 
public interface MySoapBinding { 
    ... 
} 

和實現:

@WebService(name = "MySoapBinding", targetNamespace = "http://mynamespace", endpointInterface = "my.package.MySoapBinding", serviceName = "MyService", portName = "MySoapBinding") 
public class MySoapBindingImpl 
    implements MySoapBinding 
{ 
} 

我想你可以嘗試給一個名稱的Web服務和WSDL生成的接口ated應該使用該名稱作爲綁定的名稱。

0

製作一個你喜歡的WDSL,運行wsdl2java,看看哪個sn @ ils在生成的代碼上出現,使用它們。