我正在使用SLSB和JAX-WS 註釋創建一個簡單的SOAP Web服務。我想傳遞的對象是由OGC模式生成的JAXB,感謝在java.net上的OGC項目。我遇到的一種特殊方法(其中 導致部署失敗)是請求對象(GetResult)的字段(eventTime) 與請求對象 不在同一個包中。這種類型的ObjectFactory是不同的,在編組/解組時,存在 問題。在SLSB和JAX-WS中指定JAXB包
我得到了錯誤的子集:
There's no ObjectFactory with an @XmlElementDecl for the element {http://www.opengis.net/ogc}temporalOps. this problem is related to the following location: at protected javax.xml.bind.JAXBElement net.opengis.sos.v_1_0_0.GetResult$EventTime.temporalOps at net.opengis.sos.v_1_0_0.GetResult$EventTime at protected java.util.List net.opengis.sos.v_1_0_0.GetResult.eventTime at net.opengis.sos.v_1_0_0.GetResult at public net.opengis.sos.v_1_0_0.GetResult net.opengis.sos.v_1_0_0.ObjectFactory.createGetResult() at net.opengis.sos.v_1_0_0.ObjectFactory
在標準SE應用程序,當我初始化JAXBContext而像下面 ,一切正常。
JAXBContext context = JAXBContext.newInstance("net.opengis.sos.v_1_0_0:net.opengis.sensorml.v_1_0_1:net.opengis.sos.v_1_0_0.filter.v_1_1_0");
如何在JAX-WS上下文中設置JAXB包?
我的應用程序服務器/環境是GF 3.1。
感謝您的幫助!
史蒂夫
[此博客](http://weblogs.java.net/blog/kohlert/archive/2006/10/jaxws_and_type.html)指出在服務類上使用@XmlSeeAlso看起來很有前途,但看起來像它直到JAX-WS 2.2才被採用。地鐵(通過JAX-RS RI項目)似乎支持2.2規範......但我還沒有工作。在GF 3.0.1上試用它...也許它沒有符合JAX-WS的版本。今晚稍後再試。想法,任何人? – 2011-04-13 13:29:44
@XmlSeeAlso似乎是一個很好的方法,但沒有解決問題。我被指向@UsesJAXBContext,但似乎metro有一個[bug](http://java.net/jira/browse/JAX_WS-270),它不調用JAXBContextFactory的createJAXBContext()已創建,已開放數年。調查繼續.... – 2011-04-15 12:37:07