axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis SOAPPart.java
Date Wed, 15 Jan 2003 14:06:09 GMT
dims        2003/01/15 06:06:09

  Modified:    java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis SOAPPart.java
  Log:
  Fix for Bug 16098 - NullPointerException in SOAPPart.setContent
  from cnc@trifork.com (Claus Nyhus Christensen)
  
  Fix for Bug 16099 - currentContent not set in SOAPPart object when created
  from cnc@trifork.com (Claus Nyhus Christensen)
  
  Revision  Changes    Path
  1.46      +4 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- resource.properties	10 Jan 2003 06:56:32 -0000	1.45
  +++ resource.properties	15 Jan 2003 14:06:09 -0000	1.46
  @@ -1125,3 +1125,7 @@
   foundJWS00=There is a Web Service here
   #NOTE in foundJWS01, do not translate WSDL
   foundJWS01=Click to see the WSDL
  +
  +noCharacterOrByteStream=InputSource has neither character stream nor byte stream
  +couldNotReadFromCharStream=Could not read from character stream
  +errorGetDocFromSOAPEnvelope=Could not get document from SOAPEnvelope
  \ No newline at end of file
  
  
  
  1.53      +51 -5     xml-axis/java/src/org/apache/axis/SOAPPart.java
  
  Index: SOAPPart.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SOAPPart.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- SOAPPart.java	11 Dec 2002 22:38:06 -0000	1.52
  +++ SOAPPart.java	15 Jan 2003 14:06:09 -0000	1.53
  @@ -72,6 +72,8 @@
   import javax.xml.soap.MimeHeaders;
   import javax.xml.soap.SOAPException;
   import javax.xml.transform.Source;
  +import javax.xml.transform.dom.DOMSource;
  +import javax.xml.transform.stream.StreamSource;
   import java.io.ByteArrayOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  @@ -79,6 +81,9 @@
   import java.io.StringWriter;
   import java.io.UnsupportedEncodingException;
   import java.io.Writer;
  +import java.io.Reader;
  +import java.io.BufferedReader;
  +import java.io.ByteArrayInputStream;
   import java.util.Iterator;
   import java.util.Vector;
   
  @@ -112,9 +117,6 @@
   
       //private Hashtable headers = new Hashtable();
       private MimeHeaders mimeHeaders = new MimeHeaders();
  -    private String contentId;
  -    private String contentLocation;
  -
   
       private static final String[] formNames =
       { "", "FORM_STRING", "FORM_INPUTSTREAM", "FORM_SOAPENVELOPE",
  @@ -605,7 +607,6 @@
        * Sets Content-Id of this part.
        *  already defined.
        * @param newCid new Content-Id
  -     * @returns void
        */
       public void setContentId(String newCid){
           setMimeHeader(HTTPConstants.HEADER_CONTENT_ID,newCid);
  @@ -659,7 +660,26 @@
   
           contentSource = source;
           InputSource in = org.apache.axis.utils.XMLUtils.sourceToInputSource(contentSource);
  -        setCurrentMessage(in.getByteStream(), FORM_INPUTSTREAM);
  +        InputStream is = in.getByteStream();
  +        if(is != null) {
  +            setCurrentMessage(is, FORM_INPUTSTREAM);
  +        } else {
  +            Reader r = in.getCharacterStream();
  +            if(r == null) {
  +                throw new SOAPException(Messages.getMessage("noCharacterOrByteStream"));
  +            }
  +            BufferedReader br = new BufferedReader(r);
  +            String line = null;
  +            StringBuffer sb = new StringBuffer();
  +            try {
  +                while((line = br.readLine()) != null) {
  +                    sb.append(line);
  +                }
  +            } catch (IOException e) {
  +                throw new SOAPException(Messages.getMessage("couldNotReadFromCharStream"),
e);
  +            }
  +            setCurrentMessage(sb.toString(), FORM_STRING);
  +        }    
       }
   
       /**
  @@ -672,6 +692,32 @@
        * @see #setContent(javax.xml.transform.Source) setContent(javax.xml.transform.Source)
        */
       public Source getContent() throws SOAPException {
  +    	if(contentSource == null) {
  +            switch(currentForm) {
  +            case FORM_STRING:
  +                String s = (String)currentMessage;
  +                contentSource = new StreamSource(new StringReader(s));
  +                break;
  +            case FORM_INPUTSTREAM:
  +                contentSource = new StreamSource((InputStream)currentMessage);
  +                break;
  +            case FORM_SOAPENVELOPE:
  +                SOAPEnvelope se = (SOAPEnvelope)currentMessage;
  +                try {
  +                    contentSource = new DOMSource(se.getAsDocument());
  +                } catch (Exception e) {
  +                    throw new SOAPException(Messages.getMessage("errorGetDocFromSOAPEnvelope"),
e);
  +                }
  +                break;	
  +            case FORM_BYTES:
  +                byte[] bytes = (byte[])currentMessage;
  +                contentSource = new StreamSource(new ByteArrayInputStream(bytes));
  +                break;
  +                case FORM_BODYINSTREAM:
  +                contentSource = new StreamSource((InputStream)currentMessage);
  +                break;
  +            }
  +       	}        
           return contentSource;
       }
   
  
  
  

Mime
View raw message