我创建了一个我想从Grails访问的SOAP Web服务。
我已安装插件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()
我尝试使用创建的其他Web服务,但是出现相同的错误。
我已经在Google上进行搜索,并且看到很多人都遇到了这个问题,但是我没有找到解决方法。
配置:
Windows 7 x64
Netbeans 7.2.1
Grails 2.2.0
有人知道如何解决此问题吗?
最佳答案
感谢您的回答,但问题出在插件上。为了工作,需要安装插件:
cxf
cxf客户端
安装这两个插件解决了该问题。
关于web-services - 使用WSClient调用外部SOAP Web服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15118855/