Hi Asankha,
Here is the code/message I am using.
*************************************************
CODE
*************************************************
package samples.userguide;
import java.net.URL;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
import samples.common.ErrorServiceHandler;
/**
* See build.xml for options
*/
public class ErrorClient {
private static String getProperty(String name, String def) {
String result = System.getProperty(name);
if (result == null || result.length() == 0) {
result = def;
}
return result;
}
public static void main(String[] args) {
// defaults
String mode = getProperty("mode", "1");
String addUrl = getProperty("addurl", null);
String trpUrl = getProperty("trpurl", null);
String prxUrl = getProperty("prxurl", null);
String repo = getProperty("repository", "client_repo");
String svcPolicy = getProperty("policy", null);
String rest = getProperty("rest", null);
double price = 0; int quantity = 0;
try {
Options options = new Options();
OMElement payload = null;
ServiceClient serviceClient = null;
if (repo != null && !"null".equals(repo)) {
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repo, null);
serviceClient = new ServiceClient(configContext, null);
} else {
serviceClient = new ServiceClient();
}
if ("1".equals(mode)) {
payload = ErrorServiceHandler.createRequest(2, new String[]{"DateTime,>=,2007-06-03 00:00:00.000,AND","DateTime,<=,2007-07-18 23:59:00.000,AND"});
options.setAction("urn:getError");
}
// set addressing, transport and proxy url
if (addUrl != null && !"null".equals(addUrl)) {
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
}
if (trpUrl != null && !"null".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
}
if (prxUrl != null && !"null".equals(prxUrl)) {
HttpTransportProperties.ProxyProperties proxyProperties =
new HttpTransportProperties.ProxyProperties();
URL url = new URL(prxUrl);
proxyProperties.setProxyName(url.getHost());
proxyProperties.setProxyPort(url.getPort());
proxyProperties.setUserName("");
proxyProperties.setPassWord("");
proxyProperties.setDomain("");
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
// apply any service policies if any
if (svcPolicy != null && !"null".equals(svcPolicy) && svcPolicy.length() > 0) {
serviceClient.engageModule("addressing");
serviceClient.engageModule("rampart");
options.setProperty(
RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(svcPolicy));
}
if (Boolean.parseBoolean(rest)) {
options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
}
// We do NOT want to chunk
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
serviceClient.setOptions(options);
// Send request
OMElement result = serviceClient.sendReceive(payload);
// Parse the result
ErrorServiceHandler.parseResponse(result);
} catch (Exception e) {
e.printStackTrace();
}
}
private static Policy loadPolicy(String xmlPath) throws Exception {
StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
}
package samples.common;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.xpath.AXIOMXPath;
/**
* A class that can create messages to, and parse replies from the ESB ErrorService
*/
public class ErrorServiceHandler {
public static OMElement createRequest(int numBooleanRequests, String[] input) {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("urn:au.gov.nsw.police.data.entity.xml.cim.technology.envelope.CIMMessageEnvelope.version_1_1_0_0", "");
OMElement cimMsgEnv = factory.createOMElement("CIMMessageEnvelope", ns);
OMElement header = factory.createOMElement("Header", ns);
OMElement delivery = factory.createOMElement("Delivery", ns);
OMElement message = factory.createOMElement("Message", ns);
OMElement senderMessageID = factory.createOMElement("SenderMessageID", ns);
senderMessageID.setText("n1116172");
OMElement from = factory.createOMElement("From", ns);
OMElement name = factory.createOMElement("Name", ns);
name.setText("ESBTest");
OMElement service = factory.createOMElement("Service", ns);
OMElement serviceName = factory.createOMElement("Name", ns);
serviceName.setText("getError");
OMElement namespace = factory.createOMElement("Namespace", ns);
namespace.setText("urn:au.gov.nsw.police.service.cim.technology.error.version_1_0_0_0");
service.addChild(serviceName);
service.addChild(namespace);
from.addChild(name);
message.addChild(senderMessageID);
delivery.addChild(message);
delivery.addChild(from);
header.addChild(delivery);
header.addChild(service);
cimMsgEnv.addChild(header);
OMElement payload = factory.createOMElement("Payload", ns);
OMElement document = factory.createOMElement("Document", ns);
OMNamespace nsReq = factory.createOMNamespace("urn:au.gov.nsw.police.service.cim.technology.error.version_1_0_0_0", "");
OMElement getRq = factory.createOMElement("getRq", nsReq);
// Create the ExpressionSets
for(int i=0; i < numBooleanRequests; i++){
OMElement expressionSet = createExpressionSet(input[i], factory);
getRq.addChild(expressionSet);
}
document.addChild(getRq);
payload.addChild(document);
cimMsgEnv.addChild(payload);
System.out.println(cimMsgEnv);
return cimMsgEnv;
}
public static void parseResponse(OMElement result) {
System.out.println("IN parseResponse...");
System.out.println("RESULT:");
System.out.println(result.toString());
}
/**
* Return an XML ExpressionSet
* @param input is a String delimited by a comma with 4 parts
* Left,Operation,Right,AndOrOperation
* @return OMElement - the XML representing the ExpressionSet
*/
public static OMElement createExpressionSet(String input, OMFactory factory){
// Create the Namespace and higher level elements
OMNamespace ns = factory.createOMNamespace("urn:au.gov.nsw.police.data.cim.technology.query.version_1_0_0_0", "");
OMElement expressionSet = factory.createOMElement("ExpressionSet", ns);
OMElement booleanExpression = factory.createOMElement("BooleanExpression", ns);
// Split the String into an array
String[] opNames = new String[]{"Left","Operation","Right","AndOrOpertion"};
String[] opVals = input.split(",");
// Create the repeating elements
// Finally return the ExpressionSet
}
}
*************************************************
REQUEST MESSAGE - FROM CLIENT TO ESB
*************************************************
POST / HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:getError"
User-Agent: Axis2
Host: localhost:8080
Content-Length: 1473
<soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:To>http://spc7ed01:5555/soap/esbSOAPHandler</wsa:To>
<wsa:MessageID>urn:uuid:1A7D7295DEC149D9D21184881658253</wsa:MessageID>
<wsa:Action>urn:getError</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<CIMMessageEnvelope xmlns="urn:au.gov.nsw.police.data.entity.xml.cim.technology.envelope.CIMMessageEnvelope.version_1_1_0_0">
<Header>
<Delivery>
<Message>
<SenderMessageID>n1116172</SenderMessageID>
</Message>
<From>
<Name>ESBTest</Name>
</From>
</Delivery>
<Service>
<Name>getError</Name>
<Namespace>urn:au.gov.nsw.police.service.cim.technology.error.version_1_0_0_0</Namespace>
</Service>
</Header>
<Payload>
<Document>
<getRq xmlns="urn:au.gov.nsw.police.service.cim.technology.error.version_1_0_0_0">
<ExpressionSet xmlns="urn:au.gov.nsw.police.data.cim.technology.query.version_1_0_0_0">
<BooleanExpression>
<Left>DateTime</Left>
<Operation>>=</Operation>
<Right>2007-06-03 00:00:00.000</Right>
<AndOrOpertion>AND</AndOrOpertion>
</BooleanExpression>
</ExpressionSet>
<ExpressionSet xmlns="urn:au.gov.nsw.police.data.cim.technology.query.version_1_0_0_0">
<BooleanExpression>
<Left>DateTime</Left>
<Operation><=</Operation>
<Right>2007-07-18 23:59:00.000</Right>
<AndOrOpertion>AND</AndOrOpertion>
</BooleanExpression>
</ExpressionSet>
</getRq>
</Document>
</Payload>
</CIMMessageEnvelope>
</soapenv:Body>
</soapenv:Envelope>
*************************************************
REQUEST MESSAGE - FROM ESB TO WEBMETHODS
*************************************************
POST http://spc7ed01:5555/soap/esbSOAPHandler HTTP/1.1
Host: localhost:8080
SOAPAction: urn:getError
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked
Connection: Keep-Alive
User-Agent: Synapse-HttpComponents-NIO
400
<soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><CIMMessageEnvelope xmlns="urn:au.gov.nsw.police.data.entity.xml.cim.technology.envelope.CIMMessageEnvelope.version_1_1_0_0"><Header><Delivery><Message><SenderMessageID>n1116172</SenderMessageID></Message><From><Name>ESBTest</Name></From></Delivery><Service><Name>getError</Name><Namespace>urn:au.gov.nsw.police.service.cim.technology.error.version_1_0_0_0</Namespace></Service></Header><Payload><Document><getRq xmlns="urn:au.gov.nsw.police.service.cim.technology.error.version_1_0_0_0"><ExpressionSet xmlns="urn:au.gov.nsw.police.data.cim.technology.query.version_1_0_0_0"><BooleanExpression><Left>DateTime</Left><Operation>>=</Operation><Right>2007-06-03 00:00:00.000</Right><AndOrOpertion>AND</AndOrOpertion></BooleanExpression></ExpressionSet><ExpressionSet xmlns="urn:au.gov.nsw.police.data.cim.technology.query.version_1_0_0_0"><BooleanE
fb
xpression><Left>DateTime</Left><Operation><=</Operation><Right>2007-07-18 23:59:00.000</Right><AndOrOpertion>AND</AndOrOpertion></BooleanExpression></ExpressionSet></getRq></Document></Payload></CIMMessageEnvelope></soapenv:Body></soapenv:Envelope>
0
*************************************************
RESPONSE FROM WEBMETHODS
*************************************************
HTTP/1.0 500 Internal Server Error
Set-Cookie: ssnid=2170CZuuRSkX42aOjczYyw6DyO+4omg-555530; path=/;
Content-Type: text/xml;charset=utf-8
Connection: Keep-Alive
Content-Length: 934
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>[ISS.0088.9125] SOAP request does not conform to the SOAP message model</faultstring>
<faultactor>http://localhost:8080http://spc7ed01:5555/soap/esbSOAPHandler</faultactor>
<detail xmlns:webM="http://www.webMethods.com/2001/10/soap/encoding">
<webM:validationError>
<webM:pathName>/</webM:pathName>
<webM:errorCode>NV-002</webM:errorCode>
<webM:errorMessage xml:lang="i-default">[ISC.0082.9002] Unable to retrieve root element</webM:errorMessage>
</webM:validationError>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
One thing that i am still investigating is the fact the WebMethod supports HTTP 1.1 for inbound and 1.0 for outbound so
I am a little confused as to why it can't handle my message. I will let you know if I get this resolved.
Thanks for your help
Cheers
Pete...