Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GroovyWS and complex requests

I've faced with a problem of sending complex requests with GroovyWS.

This is sample request generated by soapUI:

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:dex="http://www.temp.com/com/dex" 
>
 <soapenv:Header/>
 <soapenv:Body>
  <dex:executeRequest>
     <!--Optional:-->
     <a>?</a>
     <!--Optional:-->
     <b>?</b>
     <!--Optional:-->
     <parameters>
        <!--Zero or more repetitions:-->
        <parameter>
           <!--Optional:-->
           <key>?</key>
           <!--Optional:-->
           <value>?</value>
        </parameter>
     </parameters>
     <!--Optional:-->
     <c>?</c>
     <!--Optional:-->
     <d>?</d>
  </dex:feedrequest>
 </soapenv:Body>
</soapenv:Envelope>

the piece of groovy code:

def proxy = webService.getClient(grailsApplication.config.ws.endpoint);
proxy.processdRequest(?);

So what I should pass instead of ?.

Thanks for you help.

-vova.

like image 699
trnl Avatar asked Jul 23 '10 10:07

trnl


1 Answers

GroovyWS dynamically creates classes for each of the argument types you need in order to pass data to the web service call. For instance, if the webservice call was:

public int passSomeArgs( Arg1Type a, Arg2Type b );

GroovyWS would dynamically create an Arg1Type class and an Arg2Type class, which you could access via a method on the proxy.

// this will instantiate an Arg1Type for you
def arg1 = proxy.create( "ns1.ns2.Arg1Type" );  
// this will instantiate an Arg2Type for you
def arg2 = proxy.create( "ns1.ns2.Arg2Type" );  

You can then populate the arg1/arg2 instance with data and make your call:

int ret = proxy.passSomeArgs( arg1, arg2 );

Note, there are probably some namespaces involved in the classes being created. I used the CXF logging that was printed as GroovyWS was processing the WSDL to see what CXF thought the class names should actually be.

like image 164
billjamesdev Avatar answered Sep 18 '22 15:09

billjamesdev