6

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.

Chris
  • 8,031
  • 10
  • 41
  • 67
  • I don't remember the details at all, but what if you try to create the map parameter with `proxy.client.objectFactory.createMap()`? (the name for the last method may vary, it depends on WSDL type name) – Victor Sergienko Aug 11 '12 at 21:01

2 Answers2

3

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.

billjamesdev
  • 14,554
  • 6
  • 53
  • 76
  • Note, I got this from another answer of mine: http://stackoverflow.com/questions/3317453/groovyws-and-complex-requests/3328305#3328305 – billjamesdev Aug 12 '12 at 07:55
  • The WSDL I use does not have `ns2.Map`. How can I add it to the response? – Chris Aug 18 '12 at 12:12
  • I used ns2.Map because that's what I see in the XML snippet above. Essentially, think of namespaces as packages for this kind of thing, and include them in the name of the class you want the proxy to create. – billjamesdev Aug 18 '12 at 15:30
1

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.
Martin Spamer
  • 5,437
  • 28
  • 44