【问题标题】:JAX WS ClassCasting ErrorJAX WS 类转换错误
【发布时间】:2012-08-13 21:50:07
【问题描述】:

这是我们的 ServiceRequest.java

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ServiceRequest",
         namespace = "http://ejb.service.blue2.bcbsa.com",
         propOrder = {"any"})
public class ServiceRequest implements Serializable {
  @XmlAnyElement(lax = true)
  protected Object any;

  public Object getAny() {
    return any;
  }

  public void setAny(Object value) {
    this.any = value;
  }
}

在我的实现文件中我这样提到

IBMSOAPElement requestElement = (IBMSOAPElement)serviceRequest.getAny();

在这一行显示

java.lang.ClassCastException: org.apache.xerces.dom.ElementNSImpl incompatible with com.ibm.websphere.webservices.soap.IBMSOAPElement

【问题讨论】:

    标签: java web-services jax-ws


    【解决方案1】:

    如果不查看代码(依赖项)、WebSphere 和您安装的功能包,将很难回答这个问题。我会查看您在 JaxB (Jax-WS) 上的编译时依赖项,并确保它们是由您正在使用的 WebSphere 版本提供的。

    【讨论】:

      【解决方案2】:
      Element eobj = (Element)serviceRequest.getAny();
      
      IBMSOAPElement requestElement = (IBMSOAPElement)new SODHealper().convertDataObjectToSOAPElement(eobj);
      

      现在它工作正常!!!!!!

      【讨论】:

      • 你真的应该避免使用特定供应商的实现。此代码仅适用于 Websphere Application Server,不适用于 JBoss (WildFly) 或任何其他。
      猜你喜欢
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多