}
}
private Exchange fetchMockQuery(QName service, String operation, Element outgoingMessage, org.apache.ode.bpel.pmapi.CommunicationType.ServiceConfig serviceConfig) {
try {
MockQueryRequestDocument request = MockQueryRequestDocument.Factory.newInstance();
request.addNewMockQueryRequest().addNewIn().set(XmlObject.Factory.parse(outgoingMessage));
String xquery = serviceConfig.getReplayType().getMockQuery();
XQDataSource xqds = new SaxonXQDataSource();
XQConnection xqconn = xqds.getConnection();
net.sf.saxon.Configuration configuration = ((SaxonXQConnection) xqconn).getConfiguration();
configuration.setHostLanguage(net.sf.saxon.Configuration.XQUERY);
// XQStaticContext staticEnv = xqconn.getStaticContext();
XQPreparedExpression exp = xqconn.prepareExpression(xquery);
Node requestNode = DOMUtils.parse(request.newXMLStreamReader());
if (__log.isDebugEnabled()) {
__log.debug("request " + request.toString());
}
exp.bindItem(XQConstants.CONTEXT_ITEM, xqconn.createItemFromNode(requestNode, xqconn.createNodeType()));
XQResultSequence result = exp.executeQuery();
MockQueryResponseDocument response = MockQueryResponseDocument.Factory.parse(result.getSequenceAsStream());
{
XmlOptions opts = new XmlOptions();
List<Object> errors = new ArrayList<Object>();
opts.setErrorListener(errors);
if (!response.validate(opts)) {
__log.error("MockQuery response doesn't validate. Errors: " + errors + " Request: " + request.toString() + " Response: " + response.toString(), new Exception());
throw new IllegalStateException("MockQuery response doesn't validate.");
}
}
ResponseType response2 = response.getMockQueryResponse();