How to make a map with cxf in groovy?

GroovyWS is a framework that internally uses 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> 

I am currently trying to do this from a grails service as follows:

 def proxy = new WSClient("http://xyz", this.class.classLoader) proxy.initialize() proxy.client.invoke("call", new HashMap<String, String>()) 

What 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 it didn’t work.

+6
source share
2 answers

Well, some time has passed since I did something similar, but it looks like I remember that the clients created by CXF had a method called "create", similar to:

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

Give a try and see if mapObject has any methods or members that you expect.

+3
source

This is a known issue using JAXB

The main problem is that your circuitry is ambiguous.

There are two solutions:

  • Use name spaces to remove any ambiguity.
  • Allow each service individually in a different Java package.
+1
source

Source: https://habr.com/ru/post/922319/


All Articles