2013-03-26 64 views
0

我一直在使用websphere 7和jaxws进行web服务。 所以,如果我的web服务返回一个字符串,Integer和int或一个浮点数。当我部署它时,websphere可以识别我的web服务,但是如果我更改我的web服务以返回一个java bean;它不认可我的web服务。为什么不是websphere识别我的web服务

这是我的代码。 接口:

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; 
    } 

} 

方式it's现在工作,但如果我改变接口,实现和响应,所以他们返回一个java bean而不是一个字符串; websphere不会识别我的web服务,因此它不会显示或生成wsdl。

有谁知道为什么会发生这种情况?

在此先感谢。

+0

JAX-WS运行时可以从新的bean定义中生成WSDL(您可以在控制台输出中看到这一点)?共享库中的bean定义(Java类)在哪里?如果您使用XML简单类型,则JAXB注释不是必需的。 – 2013-03-27 02:53:08

+0

如果部署它并尝试在我的导航器中打开wsdl,但如果我的webservice返回一个对象,则不会显示它。 – linker85 2013-03-27 15:20:03

+0

并且我还需要jax注释,以便我可以在客户端执行编组和解组。 – linker85 2013-03-27 15:20:46

回答

0

如果您的web服务或服务定义存在问题,WebSphere将在应用程序启动过程中引发错误。通常你可以在你的SystemOut.log找到它。

如果您运行字符串版本,您应该找到一个日志,该服务在同一个地点成功启动。