Alan Demmin

XML String Testing

Discussion created by Alan Demmin on Oct 15, 2009
Latest reply on Oct 16, 2009 by Alan Demmin

I have created an entry point for my rule service that accepts an XML document element as an input parameter.  When I test this entry point using a simple Java deployment, everything works fine.  I am able to read an input file of strings and convert each string to an XML Element.  I then invoke the entry point with this Element.  Here is some of the Java code that is involved:

 


// Create the DOM document builder
_builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

// Obtain the DOM Document
Document requestDocument = _builder.parse(new InputSource(new StringReader(requestString)));   

// Obtain the Root Element
Element rootElement = requestDocument.getDocumentElement();

// Process the Rules
_service.processRequest(rootElement);

 

However, I am running into problems using a main() function within Blaze Advisor to do similar testing.  I would like to use strings for my test requests and convert each request to an XML Element in the same fashion as my Java deployment.  I will then call the entry point from the main().

 

The problems I am encountering are related to how to code the statements in Blaze Advisor and construct the Java objects correctly.  I have imported the following classes into the Blaze Advisor project:

 

javax.xml.parsers.DocumentBuilder

javax.xml.parsers.DocumentBuilderFactory

java.io.StringReader

org.xml.sax.InputSource

 

 

The following code produces a compiler error on the "reader":

An external class following 'a/an' must have an accessible default constructor.

 


// Open the Character Stream
reader is a StringReader initially StringReader.newInstance(header.concat(request)).

// Create the Document Source
source is a InputSource initially InputSource.newInstance(reader).

// Test the Document Root Element
LegacyFees(_builder.parse(source).documentElement).

 

The following code, compiles but gives a runtime error:

com.blazesoft.engines.rules.NdEvaluationException: Call to 'parse' failed

java.net.MalformedURLException while evaluating _builder.parse(source) 

 

// Create the Document Source
source is a InputSource initially InputSource.newInstance(      StringReader.newInstance(header.concat(request))).

// Test the Document Root Element
LegacyFees(_builder.parse(source).documentElement).

 

I think this error is related to not creating the StringReader properly within Advisor, but I can't figure out how to code the Advisor statements properly.  

 

Any ideas would be appreciated.

 

Thanks,

Alan

 

Message Edited by atdemmin on 10-15-2009 05:26 PM
Message Edited by atdemmin on 10-15-2009 05:27 PM

Outcomes