使用WSClient调用外部SOAP Web服务时出错

时间:2013-02-27 17:51:34

标签: web-services grails soap

我创建了一个SOAP Web服务,我想从Grails访问。

我已经安装了插件ws-client以使用对象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()

我尝试过我创建的其他网络服务,但我遇到了同样的错误。

我在谷歌搜索过,我看到很多人都遇到过这个问题,但我没有找到解决方法。

配置: Windows 7 x64 Netbeans 7.2.1 Grails 2.2.0

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

2 个答案:

答案 0 :(得分:1)

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

CXF

CXF的客户端

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

答案 1 :(得分:0)

来自错误消息

javac: target release 1.5 conflicts with default source release 1.7

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

相关问题