Hi,
I'm new to Groovy and Grails. I'm trying to write code that
consumes a web service (using GroovyWS). However, some of the WSDL
complex types contain simple types with restrictions based on
enumerations, and I get a GroovyCastException when trying to set the
value of the simple type.
Here is a short example of what I'm running into:
-------WSDL-------------
<complexType name="Foo">
<sequence>
<element name="fooColor" type="tns:FooColor" nillable="false"/>
<element name="bar" type="xsd:int"/>
<element name="fooName" type="xsd:string"/>
</sequence>
</complexType>
<simpleType name="FooColor">
<restriction base="xsd:string">
<enumeration value="Red"/>
<enumeration value="Black"/>
</restriction>
</simpleType>
-------/WSDL-------------
-------Groovy-------------
def proxy = new WSClient("
https://fooserver/fooBarService?WSDL", this.class.classLoader)
def myFoo= proxy .create("com.fooBarDef.Foo")
myFoo.fooColor = "Red" <---------- causes exception
-------/Groovy-------------
This is the exception from the above code:
org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object 'Red' with class 'java.lang.String' to class
'com.fooBarDef.Foo'
I would greatly appreciate any help in resolving this.
Thanks!
Bilal