axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brown, Chris" <>
Subject AXIS Serialization / Deserialization problem with namespace prefixes
Date Wed, 10 May 2006 14:49:53 GMT
  I am using the code below to serialize / deserialize AXIS beans back
and forth to XML.
  However, I have recently came across a situation where say...
  <n:test xmlns:n="http:/blah">
   Turns in to    
  <n:test xmlns:n="http:/blah">
  Once serialization / deserialization has occured.
  Does anyone know of a way to prevent this happening as it causing a
lot of problems when attempting to use
  XPath on the resulting XML document.
Many thanks in advance

This should make your boss happy:

public static Document serializeFromBinding(Object object, QName qname)
            throws ApplicationException {

        MessageContext msgContext = new MessageContext(new

        TypeMappingRegistry tmr = new TypeMappingRegistryImpl();

        StringWriter writer = new StringWriter(); //temp
        SerializationContext ser = new SerializationContext(writer,

        try {
            ser.serialize(qname, new AttributesImpl(), object, null,
Boolean.FALSE, Boolean.FALSE);
            return XMLUtils.newDocument(new InputSource(new
        catch(ParserConfigurationException e) {
            throw new ApplicationException(e.getMessage(), e);
        catch(SAXException e) {
            throw new DocumentStructureException(e.getMessage(), e);
        catch(IOException e) {
            throw new ApplicationException(e.getMessage(), e);


On Fri, 2005-11-11 at 18:10 -0500, Andy Foster wrote:
> Hi all,
> I'm at my last chance now, so if someone can help that would be great
> I'm going to have to hand code XML output.
> If you use WSDL2JAVA to generate stubs and call them you get a java
> object back that represents the XML response
> I need to get that response back into XML not the stub java
> I know axis can re serialise for me I just do not know how to invoke
> Please help as I have been searching for two days now and my boss is
> me the weekend and then we have to find another way to hand crank it
> would be a very poor solution
> Andy

Chris Brown
System Builder
Sopra Newell & Budge 

Tel	 +44 (0)131 332 3311 	 	 Fax	 +44 (0)131 332 5938

Sopra Newell & Budge, Queensway House, 1 Queensferry Terrace, Edinburgh,
EH4 3ER <>  	


Sopra Newell & Budge is the trading name of: Newell & Budge Limited (Registered in
Scotland No. 94545 with Registered Offices at: 1 Queensferry Terrace, Edinburgh, EH4 3ER,
VAT No. 774 7553 86), Newell & Budge Security Limited (Registered in Northern Ireland
No. 39008, with Registered Offices at: 199 Airport Road West, Belfast, BT3 9ED, VAT No. 774
7553 86) and Sopra Group Limited (Registered in England, No. 1588948 with Registered Offices
at: 17 St Helen's Place, London, EC3A 6DG, VAT No. 366 9784 84).

IMPORTANT NOTICE: This message is intended for the addressee only. The content may be confidential,
legally privileged and protected by law. Unauthorised use, copying or disclosure of any of
it may be unlawful. If you are not the intended recipient please notify the sender and remove
it from your system. Internet e-mails are not necessarily secure. Although we have taken steps
to ensure this e-mail and attachments are free from any virus, we advise that in keeping with
good computing practice you should ensure they are actually virus free. The right to monitor
e-mail communications through our network is reserved by Sopra Newell & Budge.
View raw message