我一直在使用 websphere 7 和 jaxws 开发网络服务。因此,如果我的网络服务返回一个字符串、整数、整数或浮点数。当我部署它时,websphere 可以识别我的 web 服务,但是如果我将 web 服务更改为返回 java bean;它无法识别我的网络服务。
这是我的代码。界面:
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface MensajeSMS {
@WebMethod
String sendMessage(Long idUsuario, String token, Integer idServicio,
String mensaje, String contacto, String idMensaje);
}
实施:
import javax.jws.WebService;
@WebService(endpointInterface = "bisnet.sms.MensajeSMS")
public class MensajeSMSImpl implements MensajeSMS {
@Override
public String sendMessage(Long idUsuario, String token, Integer idServicio,
String mensaje, String contacto, String idMensaje) {
return "Hola " + idUsuario +" "+ "tu token con Bisnet Corporativo será: " + token
+". El número telefónico que registraste es: " + idServicio
+ " y tu nombre es: " +mensaje +" " +contacto+ " " +idMensaje ;
}
}
我的请求:
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "sendMessage", namespace = "http://sms.bisnet/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "sendMessage", namespace = "http://sms.bisnet/")
public class SendMessage {
@XmlElement(name = "arg0", namespace = "")
private Long idUsuario;
@XmlElement(name = "arg1", namespace = "")
private String token;
@XmlElement(name = "arg2", namespace = "")
private Integer idServicio;
@XmlElement(name = "arg3", namespace = "")
private String mensaje;
@XmlElement(name = "arg4", namespace = "")
private String contacto;
@XmlElement(name = "arg5", namespace = "")
private String idMensaje;
/**
* @return the idUsuario
*/
public Long getIdUsuario() {
return idUsuario;
}
/**
* @param idUsuario the idUsuario to set
*/
public void setIdUsuario(Long idUsuario) {
this.idUsuario = idUsuario;
}
/**
* @return the token
*/
public String getToken() {
return token;
}
/**
* @param token the token to set
*/
public void setToken(String token) {
this.token = token;
}
/**
* @return the idServicio
*/
public Integer getIdServicio() {
return idServicio;
}
/**
* @param idServicio the idServicio to set
*/
public void setIdServicio(Integer idServicio) {
this.idServicio = idServicio;
}
/**
* @return the mensaje
*/
public String getMensaje() {
return mensaje;
}
/**
* @param mensaje the mensaje to set
*/
public void setMensaje(String mensaje) {
this.mensaje = mensaje;
}
/**
* @return the contacto
*/
public String getContacto() {
return contacto;
}
/**
* @param contacto the contacto to set
*/
public void setContacto(String contacto) {
this.contacto = contacto;
}
/**
* @return the idMensaje
*/
public String getIdMensaje() {
return idMensaje;
}
/**
* @param idMensaje the idMensaje to set
*/
public void setIdMensaje(String idMensaje) {
this.idMensaje = idMensaje;
}
}
最后是我的回应:
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "sendMessageResponse", namespace = "http://sms.bisnet/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "sendMessageResponse", namespace = "http://sms.bisnet/")
public class SendMessageResponse {
@XmlElement(name = "return", namespace = "")
private String _return;
/**
*
* @return
* returns String
*/
public String getReturn() {
return this._return;
}
/**
*
* @param _return
* the value for the _return property
*/
public void setReturn(String _return) {
this._return = _return;
}
}
它现在的工作方式,但是如果我更改接口、实现和响应,它们会返回一个 java bean 而不是字符串;websphere 无法识别我的网络服务,因此它不会显示或生成 wsdl。
有谁知道为什么会这样??
提前致谢。