网络方法返回类型和参数 : Web服务 « EJB3 « Java

En
Java
1. 图形用户界面
2. 三维图形动画
3. 高级图形
4. 蚂蚁编译
5. Apache类库
6. 统计图
7. 
8. 集合数据结构
9. 数据类型
10. 数据库JDBC
11. 设计模式
12. 开发相关类
13. EJB3
14. 电子邮件
15. 事件
16. 文件输入输出
17. 游戏
18. 泛型
19. GWT
20. Hibernate
21. 本地化
22. J2EE平台
23. 基于J2ME
24. JDK-6
25. JNDI的LDAP
26. JPA
27. JSP技术
28. JSTL
29. 语言基础知识
30. 网络协议
31. PDF格式RTF格式
32. 映射
33. 常规表达式
34. 脚本
35. 安全
36. Servlets
37. Spring
38. Swing组件
39. 图形用户界面
40. SWT-JFace-Eclipse
41. 线程
42. 应用程序
43. Velocity
44. Web服务SOA
45. 可扩展标记语言
Java 教程
Java » EJB3 » Web服务屏幕截图 
网络方法返回类型和参数



File: EmployeeBean.java


import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@Stateless
@WebService(serviceName = "EmployeeBeanService", targetNamespace = "urn:EmployeeBean")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
public class EmployeeBean implements EmployeeServiceLocal, EmployeeServiceRemote {

  public EmployeeBean() {
  }

  @WebMethod
  @WebResult(name = "bidNumber")
  public Long addBid(@WebParam(name = "User")String userId, 
      @WebParam(name = "Item")Long itemId, 
      @WebParam(name = "Price")Double bidPrice) {
    System.out.println("Bid for " + itemId + " received with price" + bidPrice);
    return 0L;
  }
}


File: EmployeeServiceLocal.java



import javax.ejb.Local;
import javax.jws.WebParam;

@Local
public interface EmployeeServiceLocal {
  public Long addBid(String userId,Long itemId,Double bidPrice);


}


File: EmployeeServiceRemote.java

import javax.ejb.Remote;


@Remote
public interface EmployeeServiceRemote {
  public Long addBid(String userId,Long itemId,Double bidPrice);
}


File: jndi.properties

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099


File: Employee.java


import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.PostRemove;

@Entity

public class Employee implements java.io.Serializable {
  private int id;

  private String firstName;

  private String lastName;

  @Id
  @GeneratedValue
  public int getId() {
    return id;
  }


  @PostRemove
  public void postRemove()
  {
     System.out.println("@PostRemove");
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getFirstName() {
    return firstName;
  }

  public void setFirstName(String first) {
    this.firstName = first;
  }

  public String getLastName() {
    return lastName;
  }

  public void setLastName(String last) {
    this.lastName = last;
  }
}


File: Main.java

import javax.ejb.EJB;
import javax.naming.InitialContext;


public class Main {

  public static void main(String[] athrows Exception {

    EmployeeServiceRemote service = null;

    // Context compEnv = (Context) new InitialContext().lookup("java:comp/env");

    // service = (HelloService)new
    // InitialContext().lookup("java:comp/env/ejb/HelloService");
    service = (EmployeeServiceRemotenew InitialContext().lookup("EmployeeBean/remote");


    //service.doAction();
    


  }

}



           
       
EJB-WebMethodWithReturnTypeAndParameters.zip( 4,489 k)
Related examples in the same category
1. EJB技术Web方法
2. 把EJB变成为Web服务
3. JBoss EJB的教程:打开的EJB到Web服务
4. 基于EJB的Web服务
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.