In the morning you always find a way to improve... :) I have noticed that last change didn't have effect on Headers, so I changed SOAPHeaders to use get/set from the MessageElement, as well as removing now unneeded outputImpl(). Changed getValue() to use defines from Constants, rather than local strings.
********************MessageElement*********** 61a62 > import org.apache.axis.encoding.Serializer; 80a82 > import java.util.Iterator; 87a90,91 > private Object mValue=null; > 207a212,241 > public Object getValue(){ > if(mValue==null){ > QName myType=getType(); > if(myType==null){ > String typeStr=attributes.getValue(Constants.NSPREFIX_SCHEMA_XSI,Constants.ATTR_TYP E); > if(typeStr!=null){ > int colPos=typeStr.indexOf(':'); > if(colPos!=-1){ > myType=new QName(typeStr.substring(0,colPos),typeStr.substring(colPos+1)); > }else{ > myType=new QName("",typeStr); > } > setType(myType); > }else{ > myType=new QName(this.getNamespaceURI(),this.getName()); > } > } > try{ > mValue=getValueAsType(myType); > }catch(Exception e){ > category.debug("getValue()",e); > } > } > return mValue; > } > > public void setValue(Object newValue){ > this.mValue=newValue; > } > 310a345,347 > if(typeQName==null){ > setType(type); > } 487a525,532 > if(mValue!=null){ > Serializer typeSerial=context.getSerializerForJavaType(mValue.getClass()); > if(typeSerial!=null){ > typeSerial.serialize(new QName(namespaceURI, name),attributes,mValue,context); > return; > } > } > 499a545,550 > if(children!=null){ > for(Iterator it=children.iterator();it.hasNext();){ > MessageElement child=(MessageElement)it.next(); > child.output(context); > } > } ********************SOAPHeader*************** 77d76 < protected Object value = null; 140,147d138 < public Object getValue() { < return value; < } < < public void setValue(Object value) { < this.value = value; < } < 152,158d142 < protected void outputImpl(SerializationContext context) throws Exception { < if (value == null) { < super.outputImpl(context); < } else { < context.serialize(new QName(namespaceURI,name), attributes, value, value.getClass() ); < } < } ********************Constants*************** 382a383 > public static final String ATTR_TYPE = "type"; ********************THE END***************** > -----Original Message----- > From: Taras Shkvarchuk > Sent: Friday, February 15, 2002 5:31 AM > To: '[EMAIL PROTECTED]' > Subject: [PATCH] message.MessageElement get/setValue() and child > serializa tion > > > org.apache.axis.message.MessageElement: > > added Object getValue()/setValue(Object) methods. > makes it a lot easier to build nodes with registered types as values. > > Fixed output() method to serialize any children node may have. > > -Taras > > 61a62 > > import org.apache.axis.encoding.Serializer; > 80a82 > > import java.util.Iterator; > 87a90,91 > > private Object mValue=null; > > > 207a212,235 > > public Object getValue() throws Exception{ > > if(mValue==null){ > > QName myType=getType(); > > if(myType==null){ > > String > typeStr=attributes.getValue("xsi","type"); > > if(typeStr!=null){ > > int colPos=typeStr.indexOf(':'); > > if(colPos!=-1){ > > myType=new > QName(typeStr.substring(0,colPos),typeStr.substring(colPos+1)); > > }else{ > > myType=new > QName("",typeStr); > > } > > setType(myType); > > } > > } > > mValue=getValueAsType(myType); > > } > > return mValue; > > } > > > > public void setValue(Object newValue){ > > this.mValue=newValue; > > } > > > 310a339,341 > > if(typeQName==null){ > > setType(type); > > } > 468a500,508 > > if(mValue!=null){ > > Serializer > typeSerial=context.getSerializerForJavaType(mValue.getClass()); > > if(typeSerial!=null){ > > typeSerial.serialize(new > QName(namespaceURI, > name),attributes,mValue,context); > > return; > > } > > } > > > > > 499a540,545 > > if(children!=null){ > > for(Iterator > it=children.iterator();it.hasNext();){ > > MessageElement > child=(MessageElement)it.next(); > > child.output(context); > > } > > } >