You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Marc Foley (JIRA)" <ax...@ws.apache.org> on 2006/06/06 19:27:33 UTC

[jira] Updated: (AXIS-1411) SimpleType for strings in the .wsdl causes type mismatch exception with axis toolkit generated code

     [ http://issues.apache.org/jira/browse/AXIS-1411?page=all ]

Marc Foley updated AXIS-1411:
-----------------------------

    Attachment: wsdl_xsd.zip

I am having the same issue in that the wsdl that gets autogenerated is not correct and when the service is called the user gets a type mismatch error.  The wsdl and xsd files are attached.

> 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: Apache Axis
>         Type: Bug

>   Components: WSDL processing, Serialization/Deserialization
>     Versions: 1.2 Beta, 1.1
>  Environment: nothing os specific here, but running on Windows 2000, with jdk 1.4.
>     Reporter: Dave Durnell
>     Priority: Minor
>  Attachments: wsdl_xsd.zip
>
> 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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org