Results 1 to 5 of 5

Thread: webServiceTemplate.marshalSendAndRecieve will not accept POJO's

  1. #1
    Join Date
    Jan 2011
    Posts
    6

    Default webServiceTemplate.marshalSendAndRecieve will not accept POJO's

    I'm trying to build a grails application to serve as a client for SOAP based web services with spring integration and WebServiceTemplate to setup the communication. When I try to use marshalSendAndRecieve() to make a call I get the following error:

    errors.GrailsExceptionResolver No signature of method: org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndRecieve() is applicable for argument types: (com.clovrmedia.web.consumerpreferenceservice.ws.d omain.RetrieveAllAccountsRequest) values: [com.clovrmedia.web.consumerpreferenceservice.ws.do main.RetrieveAllAccountsRequest@66fcc070]
    Possible solutions: marshalSendAndReceive(java.lang.Object), marshalSendAndReceive(java.lang.Object, org.springframework.ws.client.core.WebServiceMessa geCallback), marshalSendAndReceive(java.lang.String, java.lang.Object), marshalSendAndReceive(java.lang.String, java.lang.Object, org.springframework.ws.client.core.WebServiceMessa geCallback)
    groovy.lang.MissingMethodException: No signature of method: org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndRecieve() is applicable for argument types: (com.clovrmedia.web.consumerpreferenceservice.ws.d omain.RetrieveAllAccountsRequest) values: [com.clovrmedia.web.consumerpreferenceservice.ws.do main.RetrieveAllAccountsRequest@66fcc070]
    Possible solutions: marshalSendAndReceive(java.lang.Object), marshalSendAndReceive(java.lang.Object, org.springframework.ws.client.core.WebServiceMessa geCallback), marshalSendAndReceive(java.lang.String, java.lang.Object), marshalSendAndReceive(java.lang.String, java.lang.Object, org.springframework.ws.client.core.WebServiceMessa geCallback)
    at clovradmin.ConsumerController$_closure1.doCall(Con sumerController.groovy:69)
    at clovradmin.ConsumerController$_closure1.doCall(Con sumerController.groovy)
    at java.lang.Thread.run(Thread.java:662)
    I'm using Grails-1.3.4 and I have a jaxb2-marshaller configured as follows in my resources.xml

    Code:
    <oxm:jaxb2-marshaller id="marshaller" contextPath="com.clovrmedia.web.consumerpreferenceservice.ws.domain" />
    Here is the code I am trying to execute with absolutely no luck:

    Code:
    def client = applicationContext.getBean("webServiceTemplate")
    def marshaller = client.getMarshaller()
    
    marshaller.supports(com.clovrmedia.web.consumerpreferenceservice.ws.domain.RetrieveAllAccountsRequest) // yields true
    
    RetrieveAllAccountsRequest request = new RetrieveAllAccountsRequest();
    request.setClovrUserId(clovrUserId);
    request.setConsumerToken(consumerToken);
    request.setFinancialInstitutionUri(financialInstitutionURI);
    
    RetrieveAllAccountsResponse response = (RetrieveAllAccountsResponse) client.marshalSendAndRecieve(request);
    S.O.S. PLEASE HELP!!!
    Last edited by jason.burke; Jan 18th, 2011 at 02:32 PM. Reason: formatting post

  2. #2
    Join Date
    Jan 2011
    Posts
    6

    Default

    I have tracked this down to be a Groovy/Grails compiler issue..... when passing arguments to a method they're always handled very strictly typed, regardless of type casting or reassignment to a more generic type.

    In my case the method signature is: marshalSendAndRecieve(Object obj) and I'm trying to pass a POJO (plain old java object) as the parameter. I've tried such things as:

    Code:
    Object request = new RetrieveAllAcountsRequest()
    
    client.marshalSendAndRecieve((Object) request)
    and regardless the call fails at run time. Does anyone know if and how to properly cast an object in Grails? Is this a compiler bug?
    Last edited by jason.burke; Jan 19th, 2011 at 05:21 PM.

  3. #3
    Join Date
    Jan 2011
    Posts
    6

    Default

    ....as it turns out, there is no support for groovyc to send any object to a Java method using any kind of generic type or type casting if a specific type is expected.

    Code:
    def obj = request as Object // request is stored as an object in obj
    
    def response = (RetrieveAllAccountsResponse) client.marshalSendAndRecieve(obj)
    Because that does not work. Nor does this:

    Code:
    Object obj // restricting obj so that it may only hold an object
    obj = request as Object
    
    def response = (RetrieveAllAccountsResponse) client.marshalSendAndRecieve(obj)
    In these cases the obj is passed as intended, but is handled as whatever the original type was (RetrieveAllAccountsRequest).

    I often find myself answering my own questions but if anyone has any details, insight, a work around, or general thoughts on this please share them!
    Last edited by jason.burke; Jan 19th, 2011 at 05:18 PM.

  4. #4
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Are you sure this isn't all down to just a simple typo? If you take a closer look at the error:

    Code:
    groovy.lang.MissingMethodException: No signature of method: org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndRecieve() is applicable for argument types: (com.clovrmedia.web.consumerpreferenceservice.ws.d omain.RetrieveAllAccountsRequest) values: [com.clovrmedia.web.consumerpreferenceservice.ws.do main.RetrieveAllAccountsRequest@66fcc070]
    Possible solutions: marshalSendAndReceive(java.lang.Object), marshalSendAndReceive(java.lang.Object, org.springframework.ws.client.core.WebServiceMessa geCallback), marshalSendAndReceive(java.lang.String, java.lang.Object), marshalSendAndReceive(java.lang.String, java.lang.Object, org.springframework.ws.client.core.WebServiceMessa geCallback)
    you'll see that the missing method is
    Code:
    marshalSendAndRecieve()
    and Groovy suggests
    Code:
    marshalSendAndReceive(java.lang.Object)
    as a possible alternative.

    In other words, you have the 'i' and 'e' the wrong way round in 'Recieve'. Note that such things are not uncommon with dynamic languages, so it always pays to check Groovy's suggestions.

    Hope that helps,

    Peter

  5. #5
    Join Date
    Jan 2011
    Posts
    6

    Default

    Peter,

    Thank you for your close attention to detail, you are absolutely correct. I'm much happier knowing that my spelling is to blame rather than my programming intuition.

    Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •