WEB开发网
开发学院软件开发Java 在 WebSphere Application Server V7 中为 WS-Add... 阅读

在 WebSphere Application Server V7 中为 WS-Addressing 提供 JAX-WS 2.1 支持

 2010-07-26 00:00:00 来源:WEB开发网   
核心提示: 生成一个 SEI当使用清单 7 中的 WSDL 生成 SEI 后,@Action 和 @FaultAction 注释不会被自动添加,在 WebSphere Application Server V7 中为 WS-Addressing 提供 JAX-WS 2.1 支持(10),在清单 8 中的 S

生成一个 SEI

当使用清单 7 中的 WSDL 生成 SEI 后,@Action 和 @FaultAction 注释不会被自动添加。在清单 8 中的 SEI 中,我们手动添加了注释。

通过使用这个 WSDL 以及应用程序 ear 文件中的 Calculator_schema1.xsd 模式,我们可以生成一个 Service Endpoint Interface (SEI)。这可以通过使用 WebSphere Application Sever 安装的 bin 目录中的 wsimport 工具完成。生成的 SEI 如清单 8 所示。它包含 4 个方法:getTicket()、add()、getSubmissionTicket() 和 addSubmission()。 getTicket() 方法返回一个 W3CEndpointReference,而 getSubmissionTicket() 方法返回一个 SubmissionEndpointReference。add() 和 addSubmission() 方法返回一个 int,并且它们还使用 @Action 进行了注释。@Action 注释包含一个将 AddNumbersException 映射到动作 @FaultAction 注释。

清单 8. Calculator.java

  
package developerworks.jaxws.calculator; 
 
import javax.jws.WebMethod; 
import javax.jws.WebParam; 
import javax.jws.WebResult; 
import javax.jws.WebService; 
import javax.xml.bind.annotation.XmlSeeAlso; 
import javax.xml.ws.Action; 
import javax.xml.ws.FaultAction; 
import javax.xml.ws.RequestWrapper; 
import javax.xml.ws.ResponseWrapper; 
import javax.xml.ws.wsaddressing.W3CEndpointReference; 
 
import com.ibm.websphere.wsaddressing.jaxws21.SubmissionEndpointReference; 
 
@WebService(name = "Calculator", targetNamespace = 
      "http://calculator.jaxws.developerworks") 
@XmlSeeAlso({ 
  ObjectFactory.class 
}) 
public interface Calculator { 
 
  @WebMethod 
  @WebResult(targetNamespace = "") 
  @RequestWrapper(localName = "getTicket", 
         targetNamespace = "http://calculator.jaxws.developerworks", 
         className = "developerworks.jaxws.calculator.GetTicket") 
  @ResponseWrapper(localName = "getTicketResponse", 
         targetNamespace = "http://calculator.jaxws.developerworks", 
         className = "developerworks.jaxws.calculator.GetTicketResponse") 
  public W3CEndpointReference getTicket(); 
 
  @WebMethod 
  @WebResult(targetNamespace = "") 
  @RequestWrapper(localName = "getSubmissionTicket", 
        targetNamespace = "http://calculator.jaxws.developerworks", 
        className = "developerworks.jaxws.calculator.GetSubmissionTicket") 
  @ResponseWrapper(localName = "getSubmissionTicketResponse", 
        targetNamespace = "http://calculator.jaxws.developerworks", 
        className = "developerworks.jaxws.calculator.GetSubmissionTicketResponse") 
  public SubmissionEndpointReference getSubmissionTicket(); 
 
  @WebMethod 
  @WebResult(targetNamespace = "") 
  @RequestWrapper(localName = "add", 
        targetNamespace = "http://calculator.jaxws.developerworks", 
        className = "developerworks.jaxws.calculator.Add") 
  @ResponseWrapper(localName = "addResponse", 
        targetNamespace = "http://calculator.jaxws.developerworks", 
        className = "developerworks.jaxws.calculator.AddResponse") 
  @Action(input = "http://calculator.jaxws.developerworks/add", 
      output = "http://calculator.jaxws.developerworks/addResponse", 
      fault = {@FaultAction(className = AddNumbersException.class, 
      value = "http://calculator.jaxws.developerworks/addFault")}) 
  public int add( 
    @WebParam(name = "arg0", targetNamespace = "") 
    int arg0, 
    @WebParam(name = "arg1", targetNamespace = "") 
    int arg1) 
    throws AddNumbersException_Exception; 
 
  @WebMethod 
  @WebResult(targetNamespace = "") 
  @RequestWrapper(localName = "addSubmission", 
        targetNamespace = "http://calculator.jaxws.developerworks", 
        className = "developerworks.jaxws.calculator.AddSubmission") 
  @ResponseWrapper(localName = "addSubmissionResponse", 
        targetNamespace = "http://calculator.jaxws.developerworks", 
        className = "developerworks.jaxws.calculator.AddSubmissionResponse") 
  @Action(input = "http://calculator.jaxws.developerworks/addSubmission", 
      output = "http://calculator.jaxws.developerworks/addSubmissionResponse", 
      fault = {@FaultAction(className = AddNumbersException.class, 
      value = "http://calculator.jaxws.developerworks/addSubmissionFault")}) 
  public int addSubmission( 
    @WebParam(name = "arg0", targetNamespace = "") 
    int arg0, 
    @WebParam(name = "arg1", targetNamespace = "") 
    int arg1) 
    throws AddNumbersException_Exception; 
 
} 

上一页  5 6 7 8 9 10 

Tags:WebSphere Application Server

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接