Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a Map with cxf in groovy?

GroovyWS is a framework which is internally using CXF. I want to make a request as follows:

<param2 xsi:type="ns2:Map">
    <item xsi:type="ns2:Map">
        <key xsi:type="xsd:string">param1</key>
        <value xsi:type="xsd:string">param2</value>
    </item>
</param2>

Currently I am trying to do this from a grails service as following:

def proxy = new WSClient("http://xyz", this.class.classLoader)
proxy.initialize()

proxy.client.invoke("call", new HashMap<String, String>())

Which gives

javax.xml.bind.JAXBException
class java.util.HashMap nor any of its super class is known to this context.

I even tried [:] and stuff but do not get it working.

like image 714
Chris Avatar asked Aug 07 '12 20:08

Chris


2 Answers

Well, it's been a while since I did something like this, but I seem to remember that CXF-generated clients had a method called "create", similar to:

def mapObject = proxy.create( "ns2.Map" );

Give that a try and see if the mapObject has the methods or members you're expecting.

like image 134
billjamesdev Avatar answered Oct 13 '22 02:10

billjamesdev


This is a known issue with using JAXB

The underlying problem is that your schema is ambiguous.

There are two solutions:

  • Use name spaces to remove any ambiguity
  • Resolve each Service individually into a different Java package.
like image 20
Martin Spamer Avatar answered Oct 13 '22 00:10

Martin Spamer