【发布时间】:2015-01-09 03:27:54
【问题描述】:
尝试使用 SOAP UI 进行测试时..我无法获得正确的输出:
public String registerUserByuser(String user) public String getAllUsers(String userNames)
User.java
package com.ws.entity;
public class User implements java.io.Serializable{
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
private String userName;
private int userId;
}
===============================================================================
RegistrationService.java
package com.ws.Service;
import com.ws.entity.User;
public interface RegistrationService {
String registerUserByuser (String user);
User getuserNameById(int Id );
String getAllUsers (String userNames);
}
===============================================================================
RegistrationServiceImpl.java
package com.ws.test;
import javax.jws.WebMethod;
import javax.jws.WebService;
import com.ws.Service.RegistrationService;
import com.ws.entity.User;
@WebService(name = "UserWS", serviceName="RegService", portName = "CustomerPort", targetNamespace = "http://www.reg.com")
public class RegistrationServiceImpl implements RegistrationService {
@WebMethod
@Override
public String registerUserByuser(String user) {
// TODO Auto-generated method stub
User u = new User();
u.setUserId(555);
u.setUserName("Keith");
return user;
}
@WebMethod
@Override
public User getuserNameById(int Id) {
// TODO Auto-generated method stub
User a = new User();
a.setUserId(888);
a.setUserName("Seth");
return a;
}
@WebMethod
@Override
public String getAllUsers(String userNames) {
return userNames;
// TODO Auto-generated method stub
}
}
要求是开发Bottom Up WebServices: 用户注册 - 接口
方法 1 - registerUser 将用户作为输入并将字符串作为输出发送 方法 2- 将 id 作为输入并返回用户对象的 getUser 方法 3 - getAllusers 将用户列表返回给用户
我是否以错误的方式编写代码?
【问题讨论】:
-
你是什么意思...当然 getAllUsers 不会返回列表...它只是返回方法的输入参数。我在您的代码中的任何地方都看不到列表/数组...
-
在我上面提供的代码中..如何通过添加数组来打印用户?
标签: java jakarta-ee ejb-3.0