Ignore:
Timestamp:
2008-06-23T12:05:20+12:00 (16 years ago)
Author:
ak19
Message:

To avoid a Content is not allowed in Prolog exception on the side of the client which receives the XML response messages, need to ensure that the XML returned does not have illegal chars like spaces at the start of the XML. Therefore, method processInternal now converts the response to a regular string (not formatted for display), trims it to remove any whitespace chars and prefixes the <xml> tag at the start just in case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/resources/java/QBRSOAPServer.java.in

    r16050 r16103  
    729729     * @return the XML response in String format. */
    730730    protected String processInternal(Element message) {
    731         LOG.debug(this.converter.getPrettyString(message));
     731            if(LOG.isDebugEnabled()) { // or LOG.isEnabledFor(Level.DEBUG).
     732                                   // Testing for this improves efficiency
     733            LOG.debug(this.converter.getPrettyString(message));
     734        }
    732735       
    733736        // Let the messagerouter process the request message and get the response
    734         Element response = mr.process(message);
    735         // won't be null, MR always returns some response
    736        
     737        Element response = mr.process(message);
     738              // won't be null, MR always returns some response
     739       
     740        // In order to avoid "Content is not allowed in prolog" exception on the
     741        // web services' client end (problem encountered in GS mailing list), need
     742        // to make sure no characters (incl spaces) preceed the  XML sent back
     743        // from here. It may also require the <?xml?> tag at the very start.
     744        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
     745            + this.converter.getString(response).trim();
    737746        // Return it as a String formatted for display
    738         return this.converter.getPrettyString(response);
     747        // return this.converter.getPrettyString(response);
     748
    739749    }
    740750   
Note: See TracChangeset for help on using the changeset viewer.