[ http://issues.apache.org/jira/browse/AXIS-1411?page=comments#action_64220 ] Davanum Srinivas commented on AXIS-1411: ----------------------------------------
please submit a complete wsdl. thanks, dims > SimpleType for strings in the .wsdl causes type mismatch exception with axis > toolkit generated code > --------------------------------------------------------------------------------------------------- > > Key: AXIS-1411 > URL: http://issues.apache.org/jira/browse/AXIS-1411 > Project: Axis > Type: Bug > Components: Serialization/Deserialization, WSDL processing > Versions: 1.1, 1.2 Beta > Environment: nothing os specific here, but running on Windows 2000, with jdk > 1.4. > Reporter: Dave Durnell > Priority: Minor > > problem: > Let's say a .wsdl (from siebel) has this snippet: > ====== > <xsd:simpleType name="PrimaryOrganization"> > <xsd:restriction base="xsd:string"> > <xsd:maxLength value="100"/> > </xsd:restriction> > </xsd:simpleType> > ... > <xsd:complexType name="Account"> > <xsd:sequence> > <xsd:element name="AccountId" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > <xsd:element name="PrimaryOrganization" > type="xsdLocal0:PrimaryOrganization" minOccurs="0" maxOccurs="1"/> > </xsd:sequence> > </xsd:complexType> > ========== > The xsdl2java toolkit generates a PrimaryOrganization java class that starts > like this: > ====== > public class PrimaryOrganization implements java.io.Serializable, > org.apache.axis.encoding.SimpleType { > private java.lang.String value; > ===== > This results in the following error when the web service is called on, for > this data type: > ===== > - Could not convert java.lang.String to bean field 'primaryOrganization', > type com.siebel.www.xml.PrimaryOrganization > - Exception: > java.lang.IllegalArgumentException: argument type mismatch > ===== > This occurs because there is no conversion mechanism between the string and > the PrimaryOrganization, even though PrimaryOrganization is really just a > holder for the string. > 2 part Solution: > 1) Fix a bug in org.apache.axis.utils.JavaUtils::isConvertable(): If you > search for the "// If it's holder -> held or held -> holder, we're good" > comment, you'll notice that it only checks one way. It should check both ways > as follows: > ====== > // If it's holder -> held or held -> holder, we're good > Class srcHeld = JavaUtils.getHolderValueType(src); > if (srcHeld != null) { > if (dest.isAssignableFrom(srcHeld) || isConvertable(srcHeld, > dest)) > return true; > } > // the other way > destHeld = JavaUtils.getHolderValueType(dest); > if (destHeld != null) { > if (src.isAssignableFrom(destHeld) || isConvertable(destHeld, > src)) > return true; > } > ====== > 2) Generation of the SimpleType PrimaryOrganization should be a holder for > the string, starting like this instead: > ==== > public class PrimaryOrganization implements javax.xml.rpc.holders.Holder, > java.io.Serializable, org.apache.axis.encoding.SimpleType { > public java.lang.String value; > ===== -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
