简体   繁体   English

通过使用Grails Project中的wsimport生成Java调用Web服务

[英]Invoke a web service by using wsimport generation java from Grails Project

I use the wsimport to generate a Web service Client. 我使用wsimport生成Web服务客户端。 Such like 这样的

wsimport -extension -keep -p [package] [wsdl file] wsimport -extension -keep -p [程序包] [wsdl文件]

It works well by using it in java project. 通过在Java项目中使用它,效果很好。

But I want to invoke it in a Grails Project. 但是我想在Grails项目中调用它。 So I put these generated classes by wsimport into the src/java folder. 因此,我通过wsimport将这些生成的类放入src / java文件夹中。 And I invoke it in "controllers" of Grails project such as 我在Grails项目的“控制器”中调用它,例如

*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)*

Occur exception is 发生的例外是

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

I don't know which method invoke __execute method. 我不知道哪个方法调用__execute方法。 And why it works well by using java invoking, but it fails in Grails Project? 以及为什么通过使用Java调用可以很好地工作,但是在Grails Project中却失败了?


Update: 更新:

  1. Refer the https://stackoverflow.com/questions/27317033/spring-wsdl-no-corresponding-wsdl-operation-with-name to know this is about classloader issue from Spring. 请参阅https://stackoverflow.com/questions/27317033/spring-wsdl-no-corresponding-wsdl-operation-with-name,以了解这与Spring中的类加载器问题有关。

  2. I used the GGTS IDE, after it add Dependency: compile ":ws-client:1.0" into BuildConfig.groovy 在添加Dependency: compile ":ws-client:1.0"之后,我使用了GGTS IDE Dependency: compile ":ws-client:1.0"将Buildws.client Dependency: compile ":ws-client:1.0"为BuildConfig.groovy

It works. 有用。 But I still don't know the reason exactly. 但是我仍然不知道确切的原因。

I have bumped into this problem recently. 我最近遇到了这个问题。

With a Grails 2.3.9, the problem seems to be solved if you place this dependency into sour BuildConfig.groovy: 在Grails 2.3.9中,如果将此依赖项放到酸的BuildConfig.groovy中,似乎可以解决该问题:

    runtime "com.sun.xml.ws:jaxws-rt:2.1.7"

Probably, the Grails environment has an older JAX-WS runtime by default, so a newer needs to be pulled in. 默认情况下,Grails环境可能具有较旧的JAX-WS运行时,因此需要引入较新的环境。

Also, see Alex Xu-s link (in comments). 另外,请参见Alex Xu-s链接(在评论中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM