You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by He...@bcbsil.com on 2004/04/29 22:57:32 UTC

Serialization and "Not So" Simple Types




I am having an issue with attributes defined within a complex type and the
serialization of these attributes. An example below how I define the
attributes within our complex type.

      <xs:complexType name="memb-ssni-parms-type">
      <xs:attribute name="req-search-date">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:whiteSpace value="collapse"/>
            <xs:minLength value="10" />
            <xs:maxLength value="10" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      .....
      .....
      <xs:complexType>

Now the attribute is also correctly defined in the MembSsniParamsType class

        attrField = new org.apache.axis.description.AttributeDesc();
        attrField.setFieldName("reqSearchDate");
        attrField.setXmlName(new javax.xml.namespace.QName("",
"req-search-date"));
        attrField.setXmlType(new javax.xml.namespace.QName(
"http://mycompany.com/eai/memb-ssni.xsd",
">memb-ssni-parms-type>req-search-date"));
        typeDesc.addFieldDesc(attrField);

I deploy this on our Axis Server and  in the server-config.wsdd I have the
below for the attribute
            <typeMapping deserializer=
"org.apache.axis.encoding.ser.SimpleDeserializerFactory" encodingStyle=""
qname="ns3:&gt;memb-ssni-parms-type&gt;req-search-date" serializer=
"org.apache.axis.encoding.ser.SimpleSerializerFactory" type=
"java:java.lang.String" xmlns:ns3="http://mycompany.com/eai/memb-ssni.xsd"
/>

I get the following exception when I try to view the WSDL from the Axis
services page..

AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
 faultSubcode:
 faultString: Bean attribute req-search-date is of type java.lang.String,
which is not a simple type
 faultActor:
 faultNode:
 faultDetail:
      {http://xml.apache.org/axis/}stackTrace:AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
 faultSubcode:
 faultString: Bean attribute req-search-date is of type java.lang.String,
which is not a simple type
 faultActor:
 faultNode:
 faultDetail:

Bean attribute req-search-date is of type java.lang.String, which is not a
simple type
      at
org.apache.axis.encoding.ser.BeanSerializer.writeAttribute(BeanSerializer.java:443)
      at
org.apache.axis.encoding.ser.BeanSerializer.writeSchema(BeanSerializer.java:344)
      at
org.apache.axis.wsdl.fromJava.Types.makeTypeElement(Types.java:1713)
      at
org.apache.axis.wsdl.fromJava.Types.writeElementDecl(Types.java:1171)
      at
org.apache.axis.wsdl.fromJava.Emitter.writePartToMessage(Emitter.java:1827)
      at
org.apache.axis.wsdl.fromJava.Emitter.writeRequestMessage(Emitter.java:1386)
      at
org.apache.axis.wsdl.fromJava.Emitter.writeMessages(Emitter.java:1034)
      at
org.apache.axis.wsdl.fromJava.Emitter.writePortType(Emitter.java:1005)
      at org.apache.axis.wsdl.fromJava.Emitter.getWSDL(Emitter.java:459)
      at org.apache.axis.wsdl.fromJava.Emitter.emit(Emitter.java:310)
      at
org.apache.axis.providers.BasicProvider.generateWSDL(BasicProvider.java:228)
      at
org.apache.axis.strategies.WSDLGenStrategy.visit(WSDLGenStrategy.java:33)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      at org.apache.axis.SimpleChain.generateWSDL(SimpleChain.java:104)
      at
org.apache.axis.handlers.soap.SOAPService.generateWSDL(SOAPService.java:373)
      at
org.apache.axis.server.AxisServer.generateWSDL(AxisServer.java:467)





After digging through the Axis code, I find that it fails on this method in
the  org.apache.axis.wsdl.fromJava.Types class

    boolean isSimpleType(Class type) {

        QName qname = tm.getTypeQName(type);

        if (qname == null) {
            return false;    // No mapping
        }

        String nsURI = qname.getNamespaceURI();

        return (Constants.isSchemaXSD(nsURI) ||
Constants.isSOAP_ENC(nsURI));
    }


In the above code type is String.class and it looks up the associated QName
in the registry and gets me back
{http://mycompany.com/eai/memb-ssni.xsd}>memb-ssni-parms-type>req-search-date

And this fails on the last line of the method Constants.isSchemaXSD(nsURI)
as this is not in the default Schema namespace.


First off, is this a bug? Because, it is still a simple type but it has the
namespace of the document rather than the default Schema namespace and I
add extensions on the simple type

What can I do to fix this?
Do I define a custom serializer that extends SimpleSerializer?
Can I change something on the schema?

Any help appreciated.

Thanks
Hemanth Setty



------------------------------------------------------------------------------
**********
The information contained in this communication is confidential, private,
proprietary, or otherwise privileged and is intended only for the use of the
addressee.  Unauthorized use, disclosure, distribution or copying is strictly
prohibited and may be unlawful.  If you have received this communication in
error, please notify the sender immediately at (312)653-6000 in Illinois;
(972)766-6900 in Texas; or (800)835-8699 in New Mexico.
**********
==============================================================================