protected ProtocolIndependentMessage doInternalRequest( String deviceName,
String messageXML,
String characterEncoding )
throws MessageException {
ProtocolIndependentMessage rawMessage = null;
try {
InternalConfig internalConfig = new InternalConfig();
InternalRequest internalRequest = new InternalRequest( deviceName,
"mps" );
InternalResponse internalResponse = new InternalResponse();
MarinerRequestContext requestContext =
new MarinerInternalRequestContext( internalConfig,
internalRequest,
internalResponse,
null );
// set character encoding if not null
if (characterEncoding != null) {
requestContext.setCharacterEncoding(characterEncoding);
}
// Parse the contents of the response as Marlin markup.
// The processed page will be written to the response, so
// we don't need to do anything further.
XMLReader reader =
MarlinSAXHelper.getXMLReader( requestContext, null );
EnvironmentContext environmentContext =
ContextInternals.getEnvironmentContext( requestContext );
// The getXMLReader() call above will set up the pipelineContext in
// the environmentContext. See MarlinSAXHelper.setPipelineContext()
XMLPipelineContext pipelineContext =
environmentContext.getPipelineContext();
// set the Base URI in the pipeline's context
try {
URL baseURI = new URL( baseUrl );
if( logger.isDebugEnabled() ) {
logger.debug( "Setting Base URI "
+ baseURI.toExternalForm() );
}
pipelineContext.pushBaseURI( baseURI.toExternalForm() );
} catch( MalformedURLException e ) {
throw new MessageException( e );
}
reader.parse( new InputSource( new StringReader( messageXML ) ) );
MPSApplicationContext applicationContext =
(MPSApplicationContext)ContextInternals.getApplicationContext(
requestContext );
applicationContext.getAssetMap();
// set charset type for content
String contentType = getContentTypeHeader(
internalResponse.getContentType(),
characterEncoding);
rawMessage = new ProtocolIndependentMessage(
internalResponse.getResponseAsString(),
contentType,
applicationContext.getAssetMap(),
characterEncoding);
rawMessage.setBaseURL( new URL( baseUrl ) );
rawMessage.setMaxFileSize( applicationContext.getMaxFileSize() );
rawMessage.setMaxMMSize( applicationContext.getMaxMMSize() );
requestContext.release();
} catch (SAXException se) {
Exception cause = se.getException();
// Check the root cause of the SAXException, as it may not be