2013-02-27 102 views
0

我已經創建了一個我想從Grails訪問的SOAP Web服務。使用WSClient調用外部SOAP Web服務時出錯

我已經安裝了插件WS-客戶端才能使用該對象WSClient。

我試圖在這裏給出的例子:http://groovy.codehaus.org/Using+WSClient+in+Grails

所以我的代碼是:

def index = { 

def proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader) 
proxy.initialize() 

def result = proxy.CelsiusToFahrenheit(0) 
result = "You are probably freezing at ${result} degrees Farhenheit" 
flash.message = result 
} 

這是錯誤我得到:

javac: target release 1.5 conflicts with default source release 1.7 
| Error 2013-02-27 17:47:06,901 [http-bio-8080-exec-10] ERROR errors.GrailsExceptionResolver - JAXBException occurred when processing request: [POST] /WordGame/game/create 
"org.tempuri" doesnt contain ObjectFactory.class or jaxb.index. Stacktrace follows: 
Message: "org.tempuri" doesnt contain ObjectFactory.class or jaxb.index 
    Line | Method 
->> 197 | createContext in com.sun.xml.bind.v2.ContextFactory 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 172 | newInstance in javax.xml.bind.ContextFinder 
| 132 | newInstance . in  '' 
| 334 | find   in  '' 
| 431 | newInstance . in javax.xml.bind.JAXBContext 
| 349 | createClient in org.apache.cxf.endpoint.dynamic.DynamicClientFactory 
| 196 | createClient in  '' 
| 175 | createClient in  '' 
| 198 | createClient in groovyx.net.ws.AbstractCXFWSClient 
| 107 | initialize in groovyx.net.ws.WSClient 
|  30 | conversion . in wordgame.GameController$$ENyfXWG9 
|  42 | doCall  in wordgame.GameController$_closure1$$ENyfXWG9 
| 195 | doFilter . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter 
|  63 | doFilter  in grails.plugin.cache.web.filter.AbstractFilter 
| 1110 | runWorker . . in java.util.concurrent.ThreadPoolExecutor 
| 603 | run   in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 722 | run . . . . . in java.lang.Thread 

我知道有沒有錯誤調用方法proxy.CelsiusToFahrenheit(0),因爲我有同樣的錯誤只是在做:

def proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader) 
proxy.initialize() 

我試圖用我已經創建了一個Web服務等,但我有同樣的錯誤。

我對谷歌搜索,我已經看到了很多有這個問題的人,我沒有找到如何解決它。

配置: Windows 7的64位 Netbeans的7.2.1 的Grails 2.2.0

難道有人知道如何解決這個問題?

回答

0

從錯誤信息

javac: target release 1.5 conflicts with default source release 1.7 

,我認爲它是關於JDK版本。 WSClient需要JDK在運行時編譯一些東西,所以你必須部署一個1.7版本的JDK來支持它。

+0

此消息剛剛消失的時候我已經安裝了CXF插件 – Chewbye 2013-03-01 11:36:54

1

感謝您的回答,但問題是從插件。爲了工作,這是必須安裝的插件:

CXF

CXF的客戶端

安裝這兩個插件解決了這個問題。

+0

我發現WS-客戶端插件http://grails.org/plugin/ws-client多更巧妙的使用。雖然安裝cxf是必需的。 – 2014-06-06 17:25:38