BeanSerializer is not adding xsi:type if the value of the field is null.  If xsi:type is missing then the server is not able to deserialize.
 
I am using axis nightly drop of 05-31 on client side and soap toolkit which comes along with Websphere on the server end.  Does any one experience the same problem?
 
Here is the SOAP xml generated by Axis
 
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:baseletGetIds xmlns:ns1="http://boulder.ibm.com/com.ibm.pdc.cis.sri.baselet.BaseletBean">
   <searchParameter href="#id0"/>
  </ns1:baseletGetIds>
  <multiRef id="id0" SOAP-ENC:root="0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:com.ibm.pdc.cis.sri.baselet.domain.BaseletSearchBean" xmlns:ns2="http://www.baseletbean.com/schemas/BaseletBeanRemoteInterface">
   <ns2:baseletRole xsi:nil="true"/>
   <ns2:baseletName xsi:nil="true"/>
   <ns2:baseletDirectoryLocation xsi:nil="true"/>
   <ns2:baseletModificationStartDate xsi:nil="true"/>
   <ns2:baseletClinicalCondition xsi:nil="true"/>
   <ns2:baseletModificationEndDate xsi:nil="true"/>
   <ns2:baseletType xsi:nil="true"/>
   <ns2:baseletState xsi:type="xsd:int">1</ns2:baseletState>
   <ns2:baseletHasBeenInserted xsi:nil="true"/>
   <ns2:baseletSource xsi:nil="true"/>
   <ns2:baseletIsEnterprise xsi:nil="true"/>
   <ns2:baseletCreationStartDate xsi:nil="true"/>
   <ns2:baseletHasLinks xsi:nil="true"/>
   <ns2:baseletAuthorId xsi:nil="true"/>
   <ns2:baseletClinicalDomain xsi:nil="true"/>
   <ns2:baseletKeyword xsi:nil="true"/>
   <ns2:baseletCreationEndDate xsi:nil="true"/>
   <ns2:baseletLanguage xsi:nil="true"/>
   <ns2:baseletSponsor xsi:nil="true"/>
   <ns2:CMTId xsi:nil="true"/>
  </multiRef>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 
 
There are two things which are wrong
 
1) the xsi:type is missing if the objec property value is null
2) It is adding namespace before each property of the bean.
 
I looked into the C:\xml-axis\java\src\org\apache\axis\encoding\SerializationContextImpl.java for the problem 1 i.e missing the type
In the serialize method if the attribute value is null populating the xmlType is missing.
 
Old code
 
        if (value == null) {
            // If the value is null, the element is
            // passed with xsi:nil="true" to indicate that no object is present.
            if (sendNull) {
                AttributesImpl attrs = new AttributesImpl();
                if (attributes != null && 0 < attributes.getLength())
                    attrs.setAttributes(attributes);
                if (sendType)
                    attrs = (AttributesImpl) setTypeAttribute(attrs, xmlType);
                attrs.addAttribute(Constants.NS_URI_2001_SCHEMA_XSI, "nil", "xsi:nil",
                                   "CDATA", "true");
                System.out.println("KKK: elemQName=" + elemQName);
                startElement(elemQName, attrs);
                endElement();
            }
            return;
        }
 
Modification required
 
        if (value == null) {
            // If the value is null, the element is
            // passed with xsi:nil="true" to indicate that no object is present.
            if (sendNull) {
                AttributesImpl attrs = new AttributesImpl();
                if (attributes != null && 0 < attributes.getLength())
                    attrs.setAttributes(attributes);
                if (sendType) { // Here the xmlType needs to obtained from the typemapping.
                     TypeMapping tm = getTypeMapping();
                    if (xmlType == null) {
                        xmlType = tm.getTypeQName(javaType);
                    }
                    attrs = (AttributesImpl) setTypeAttribute(attrs, xmlType);
                    }
                attrs.addAttribute(Constants.NS_URI_2001_SCHEMA_XSI, "nil", "xsi:nil",
                                   "CDATA", "true");
                System.out.println("KKK: elemQName=" + elemQName);
                startElement(elemQName, attrs);
                endElement();
            }
            return;
        }
 
Please let me know if I am wrong and please suggest me where to look for the namespace issue.
 
Thanks in advance
Kesav Kumar
 

Reply via email to