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 ae...@rbc.com on 2005/03/09 17:57:48 UTC

.NET and Axis

Hi, 

I have posted emails on this topic before but have never really understood the problem I was experiencing until now. Sorry for any misleading mails up to this point. I also apologise in advance for the length of this mail.  Hopefully people can understand what I am getting at!

The problem (as I now understand it) is that in order to use a wrapped/literal service to send data between .NET and Axis, the Java Bean property names need to start with an UPPER case character in the XML.  

Easier to explain with code I think.... 

The Java Bean class can have the property name in lower case, e.g., stringValue 

private java.lang.String stringValue; 

but must serialise it to start with an upper case character, e.g., StringValue 

org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); 
        elemField.setFieldName("stringValue"); 
        elemField.setXmlName(new javax.xml.namespace.QName("urn:ionic.webservices.2005.03.Types", "StringValue")); 
        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); 
        elemField.setNillable(true); 
        typeDesc.addFieldDesc(elemField); 

so that the c# class has properties that start with upper case, e.g., StringValue not stringValue 

[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:ionic.webservices.2005.03.Types")] 
    public class MyComplexType { 
        
        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] 
        public string StringValue; 
        
        /// <remarks/> 
        public int IntValue; 
        
        /// <remarks/> 
        public System.DateTime DateTimeValue; 
        
        /// <remarks/> 
        public System.DateTime Created; 
        
        /// <remarks/> 
        public System.Single FloatValue; 
        
        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute("ChildObjects", IsNullable=true)] 
        public MyComplexType[] ChildObjects; 
    } 

If I don't include the Axis generated Custom Serializer and Deserializer in my classes (coz I have tons of existing classes that have lots of comments in them and existed before I needed to expose my application using web services), Axis uses org.apache.axis.encoding.ser.BeanDeserializerFactory for the serialization which means that the c# properties are generated with the same case as the Java class, i.e., starting with a lower case letter, and the data is not serialized correctly. 

For example, if the following code is executed from a .NET client 

CTSOAP service = new CTSOAP(); 

MyComplexType type = service.getComplexType("caller"); 

type is not null but type.stringValue is an empty string. 

If I use the Axis generated classes, then the properties are serialized and deserialized using properties where the first character is Upper case and this solves the problem.

I don't want to use the Axis generated classes for the reasons specified above, but do I have any choice if I want to go to wrapped/literal?  

This problem does not exist for rpc/encoded. 

Any comments would be appreciated. 


____________________________________________________________
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. 

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.

============================================================