axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/message MessageElement.java
Date Thu, 21 Feb 2002 04:01:49 GMT
gdaniels    02/02/20 20:01:48

  Modified:    java/src/org/apache/axis/message MessageElement.java
  Log:
  In case there isn't a deserialization context available when trying to
  string-ize a MessageElement (for instance, when the MessageElement
  has been dynamically created), just use whatever the current
  MessageContext is to get the TypeMappings which are in scope.
  
  This fixes a bug discovered by Romin Irani (thanks, Romin!)
  
  Revision  Changes    Path
  1.75      +18 -17    xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- MessageElement.java	19 Feb 2002 17:38:21 -0000	1.74
  +++ MessageElement.java	21 Feb 2002 04:01:48 -0000	1.75
  @@ -412,24 +412,30 @@
   
       public Document getAsDocument() throws Exception
       {
  +        String elementString = getAsString();
  +
  +        Reader reader = new StringReader(elementString);
  +        Document doc = XMLUtils.newDocument(new InputSource(reader));
  +        if (doc == null)
  +            throw new Exception(
  +                    JavaUtils.getMessage("noDoc00", elementString));
  +        return doc;
  +    }
  +
  +    private String getAsString() throws Exception {
           SerializationContext serializeContext = null;
           StringWriter writer = new StringWriter();
  -        if(context != null)
  -        {
  -            MessageContext msgContext = context.getMessageContext();
  -            serializeContext = new SerializationContextImpl(writer, msgContext);
  +        MessageContext msgContext;
  +        if (context != null) {
  +            msgContext = context.getMessageContext();
           } else {
  -            serializeContext = new SerializationContextImpl(writer);
  +            msgContext = MessageContext.getCurrentContext();
           }
  +        serializeContext = new SerializationContextImpl(writer, msgContext);
           output(serializeContext);
           writer.close();
   
  -        Reader reader = new StringReader(writer.getBuffer().toString());
  -        Document doc = XMLUtils.newDocument(new InputSource(reader));
  -        if (doc == null)
  -            throw new Exception(
  -                    JavaUtils.getMessage("noDoc00", writer.getBuffer().toString()));
  -        return doc;
  +        return writer.getBuffer().toString();
       }
   
       public Element getAsDOM() throws Exception
  @@ -503,12 +509,7 @@
   
       public String toString() {
           try {
  -            StringWriter  writer = new StringWriter();
  -            SerializationContext serContext = new SerializationContextImpl(writer, 
  -                                                                           null);
  -            serContext.setSendDecl(false);
  -            this.output(serContext);
  -            return( writer.toString() );
  +            return getAsString();
           }
           catch( Exception exp ) {
               exp.printStackTrace();
  
  
  

Mime
View raw message