因此,我嘗試用Spring和JAX-WS 2.2.10編寫SOAP @WebService。進入功能參數的JAX-WS webservice和@XmlAnyElement
部分看起來是這樣的:
package com.itu.messaging.regional;
import org.w3c.dom.Element;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "GenericMessagePrimaryContent", propOrder = {
"any"
})
public class GenericMessagePrimaryContent implements Serializable {
@XmlAnyElement
protected Element any;
/**
* Gets the value of the any property.
*
* @return
* possible object is
* {@link Element }
*
*/
public Element getAny() {
return any;
}
/**
* Sets the value of the any property.
*
* @param value
* allowed object is
* {@link Element }
*
*/
public void setAny(Element value) {
this.any = value;
}
}
但是,當我部署我的代碼(並希望看到生成的WSDL) - 我得到這個異常:java.lang.ClassCastException: com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$26 cannot be cast to com.sun.xml.bind.v2.model.core.EnumLeafInfo
。
因此,最有趣的是,在Glassfish Metro 2.3.1 XmlSchemaGenerator.java
中,該異常拋出XmlSchemaGenerator.java
,但不是JAX-WS XmlSchemaGenerator。
我的項目有很多模塊,但是這個模塊在他的pom.xml中沒有鏈接到metro,它只有另一個模塊。爲什麼這個問題可以成爲?