Grails consume SOAP with WSDL + pojo / pogo?

I need to call some SOAP webservices in my grails application (grails 2.4.5 + groovy 2.3) and ideally I would like to do it using the WSDL description since everything is set up in it (actions, options, return, ... ). 1 month with hands on the grail, 3 years on JAVA, not on web services.


First, it seems that I should forget the "so easy and already packaged" thing about using GroovyWS , since the project seems to be abandoned and the links are brown. Too bad.


Then I went to look at the grails CXF plugin ( Grails CXF plugin ). After hours of work developing the CXF plugin project and Plugin demo project, I was able to create about 30 java classes from my WSDL, but was unable to inject anything into my controller using syntax like this:

class DemoController {
SimpleServicePortType simpleServiceClient
ComplexServicePortType complexServiceClient

def simpleServiceDemo = {
    SimpleRequest request = new SimpleRequest(age: 100, name: "Bob")
    SimpleResponse response = simpleServiceClient.simpleMethod(request)

    render(view: '/index', model: [simpleRequest: request, simpleResponse: response])
}

      

I have created a WSSessionSOAP class which seems to be perfect (every operation, parameters, ...), but what an interface ... In the project example, I saw that the developer defines the behavior of the services, so I think it is more "exposing" WS, than consuming it. Is it really possible to create classes from WSDL and use them to invoke SOAP services? It would seem so natural!


Finally , I looked at the Grails WSlite Plugin and was able to call WS (yay!) Like this:

withSoap(serviceURL: 'https://XXX/webservices/session.asmx') {
  def response = send(SOAPAction: 'http://XXX/Session/CheckSession') {
    body {
      CheckSession(xmlns : 'http://XXX/Session') { guid(chaine) }
    }
  }
  render response.CheckSessionResponse.CheckSessionResult.text()
}

      

This is the first step, OK for simple services (for now), but I feel like reinventing the wheel and not capitalizing on the OO aspect of WSDL.

Is this a good / best / only way to use SOAP services (with pure Grails services, of course)? Does the CXF plugin have a chance to meet my needs? What did I miss? I have read so many pages but in most cases the examples are too generic or out of date.


I know there are other solutions as well:

  • Using the full Java API to create the "WebServices" part and use it in my Grail services / controllers, but again, what's the best way to do this?
  • Call my WS with the good old HTTP GET requests. Wouldn't it be an insult?

Sorry if I can consider absurd options, but this is driving me crazy, I feel like I was spending too much time on this because the result is only a "0" answer for a bit of WS.

Feel free to ask me anything I would forget. Thank you for your help!

+3


source to share





All Articles