简体   繁体   English

Grails和使用SOAP Web服务

[英]Grails and consume SOAP webservice

Being fairly new to Grails i was wondering what people use to consume a webservice in Grails projects. 作为Grails的新手,我想知道人们在Grails项目中使用什么来使用Web服务。 So the client side of the system? 那么系统的客户端呢? Any recommendations? 有什么建议? I see people using GroovyWS, Spring-WS etc.. What is a good and easy on to use? 我看到人们使用GroovyWS,Spring-WS等。什么是好用且易于使用?

GroovyWS非常易于使用,并且有很好的文档,我肯定会推荐它。

Using Grails CXF plugin here. 在这里使用Grails CXF插件。 Needed: 需要:

  1. classloader workaround - DynamicClientFactoryit changed a current classloader; classloader变通方法 - DynamicClientFactoryit更改了当前的类加载器;
  2. and to code WS invocations by hand. 并手动编写WS调用。

Besides that, the consumer code is pretty slim. 除此之外,消费者代码相当渺茫。

Edit: sorry, no more then this, and I'm not sure I'm not breaking and NDA yet: 编辑:对不起,不再是这个,我不确定我还没破坏和NDA:

#1: #1:

def arrayOfLong = objectFactory.createArrayOfLong(XXX, ids)
result = client.invoke(methodName, arrayOfLong as Object[])

#2: #2:

def dcf = DynamicClientFactory.newInstance()
def classLoader = Thread.currentThread().getContextClassLoader()

// create a WS client
// and assign end point address to it
def client = dcf.createClient(WSDL_URL, classLoader)
client.conduit.target.address.setValue(endpointUrl)

// reacquire classloader because 'createClient' changes it
def changedClassLoader = Thread.currentThread().getContextClassLoader()
def objectFactory = changedClassLoader.
    loadClass(FACTORY_CLASS_NAME).newInstance()

Using Grails 1.3.7 I am consuming my own web service with WS-Client Grails plugin . 使用Grails 1.3.7我使用WS-Client Grails插件使用自己的Web服务。 It is actually based on GroovyWS, which in turn uses CXF. 它实际上基于GroovyWS,而GroovyWS又使用CXF。 It is very easy to use at least in my simple scenario, where I only get Strings from the backend web service. 它至少在我的简单场景中非常容易使用,我只从后端Web服务获得字符串。 I have no idea how it works with complex data types yet though. 我不知道它如何适用于复杂的数据类型。

I had never consumed or created a webservice before but using that plugin in the frontend and the Grails CXF plugin in the backend I got a SOAP discussion between my grails apps in two days. 我以前从未消费或创建过webservice,但是在前端使用该插件并在后端使用Grails CXF插件我在两天内在我的grails应用程序之间进行了SOAP讨论。 You don't really need to use CXF or GroovyWS directly with the very nice ws-client plugin. 你真的不需要直接使用非常好的ws-client插件使用CXF或GroovyWS。 Speed (of development) and simplicity. 速度(发展)和简单。

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

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