【问题标题】:Why isn´t websphere recognizing my webservice为什么 websphere 不能识别我的网络服务
【发布时间】:2013-03-26 23:32:37
【问题描述】:

我一直在使用 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。

有人知道为什么会这样吗?

提前致谢。

【问题讨论】:

  • JAX-WS 运行时能否从您的新 bean 定义中生成 WSDL(您可以在控制台输出中看到这一点)?共享库中的 bean 定义(Java 类)在哪里?如果使用 XML 简单类型,则不需要 JAXB 注释。
  • 如果部署它并尝试在我的导航器中打开 wsdl,如果我的 web 服务返回一个对象,它不会出现。
  • 我还需要 jax 注释,以便在客户端进行编组和解组。
  • 对象类在哪里?罐子里有吗?在共享库中?像服务接口和实现一样在同一个包里?

标签: java web-services jax-ws websphere-7


【解决方案1】:

如果您的 Web 服务或服务定义有问题,WebSphere 将在应用程序启动期间抛出错误。通常你可以在你的SystemOut.log找到它。

如果您运行字符串版本,您应该会在同一位置找到服务已成功启动的日志。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多