0

我创建了一个希望从 Grails 访问的 SOAP Web 服务。

为了使用对象 WSClient,我已经安装了插件 ws-client。

我试过这里给出的例子: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 x64 Netbeans 7.2.1 Grails 2.2.0

有人知道如何解决这个问题吗?

4

2 回答 2

1

感谢您的回答,但问题出在插件上。为了工作,需要安装插件:

CXF

cxf-客户端

安装这两个插件解决了这个问题。

于 2013-02-28T18:27:14.200 回答
0

从错误信息

javac: target release 1.5 conflicts with default source release 1.7

我认为这与JDK版本有关。WSClient 需要 JDK 来在运行时编译一些东西,所以你必须部署一个 1.7 版本的 JDK 来支持它。

于 2013-02-28T03:32:54.897 回答