我使用wsimport 生成Web 服务客户端。比如
wsimport -extension -keep -p [程序包] [wsdl 文件]
在java项目中使用它效果很好。
但我想在 Grails 项目中调用它。 所以我将 wsimport 生成的这些类放入 src/java 文件夹中。 我在 Grails 项目的“ Controller ”中调用它,例如
*Holder<String> result = new Holder<String>()
Holder<String> description = new Holder<String>()
RCCWebServiceClientHandler.createSubscription(591, "1234", "1234324543", "453452345", "", 0, "78",4, "", "", result, description)
println(result.value)
println(description.value)*
发生异常的是
2015-03-19 17:44:13,162 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver - WebServiceException occurred when processing request: [GET] /GrailsExample/webservice/index
Method __execute is exposed as WebMethod, but there is no corresponding wsdl operation with name __execute in the wsdl:portType{http://syniverse.com}soap. Stacktrace follows:
Message: Method __execute is exposed as WebMethod, but there is no corresponding wsdl operation with name __execute in the wsdl:portType{http://syniverse.com}soap
Line | Method
->> 341 | freeze in com.sun.xml.internal.ws.model.JavaMethodImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 94 | freeze in com.sun.xml.internal.ws.model.AbstractSEIModelImpl
| 240 | buildRuntimeModel . . in com.sun.xml.internal.ws.model.RuntimeModeler
| 672 | createSEIPortInfo in com.sun.xml.internal.ws.client.WSServiceDelegate
| 660 | addSEI . . . . . . . . in ''
| 329 | getPort in ''
| 312 | getPort . . . . . . . in ''
| 294 | getPort in ''
| 119 | getPort . . . . . . . in javax.xml.ws.Service
| 72 | getSoapServiceImplPort in com.syniverse.sponsordata.ws.client.Soap_Service
| 38 | createSubscription . . in com.syniverse.sponsordata.ws.client.handler.RCCWebServiceClientHandler
| 16 | ws in com.syniverse.sponsordata.GroovyTest
| 15 | index . . . . . . . . in grailsexample.WebserviceController
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
我不知道哪个方法调用 __execute 方法。为什么使用java调用可以很好地工作,但在Grails项目中却失败了?
<小时/>更新:
请参阅https://stackoverflow.com/questions/27317033/spring-wsdl-no-corresponding-wsdl-operation-with-name要知道这是关于 Spring 的类加载器问题。
我用的是GGTS IDE,在它添加后
依赖关系: 编译“:ws-client:1.0”
进入 BuildConfig.groovy
它有效。但具体原因我还是不太清楚。
最佳答案
我最近遇到了这个问题。
使用 Grails 2.3.9,如果将此依赖项放入 sour BuildConfig.groovy 中,问题似乎就可以解决:
runtime "com.sun.xml.ws:jaxws-rt:2.1.7"
Grails 环境可能默认具有较旧的 JAX-WS 运行时,因此需要引入较新的运行时。
另外,请参阅 Alex Xu 的链接(在评论中)。
关于java - 使用 Grails 项目中的 wsimport 生成 java 调用 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29142013/