use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class XmlRpcConverter method toXmlRpcRequest.
@Converter
public static XmlRpcRequest toXmlRpcRequest(final List<?> parameters, Exchange exchange) {
// get the message operation name
String operationName = exchange.getIn().getHeader(XmlRpcConstants.METHOD_NAME, String.class);
// create the request object here
XmlRpcRequest request = new XmlRpcRequestImpl(operationName, parameters);
return request;
}
use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class XmlRpcDataFormat method marshal.
@Override
public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
// need to check the object type
XMLWriter control = getXMLWriter(exchange, stream);
XmlRpcWriter writer = new XmlRpcWriter(xmlRpcStreamRequestConfig, control, typeFactory);
XmlRpcRequest request = null;
if (isRequest || graph instanceof XmlRpcRequest) {
request = exchange.getContext().getTypeConverter().mandatoryConvertTo(XmlRpcRequest.class, exchange, graph);
}
if (request != null) {
writer.writeRequest(xmlRpcStreamRequestConfig, request);
} else {
// write the result here directly
// TODO write the fault message here
writer.write(xmlRpcStreamRequestConfig, graph);
}
}
use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class XmlRpcDataFormatTest method testRequestMessage.
@Test
public void testRequestMessage() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:request");
mock.expectedMessageCount(1);
XmlRpcRequest result = template.requestBody("direct:request", new XmlRpcRequestImpl("greet", new Object[] { "you", 2 }), XmlRpcRequest.class);
assertNotNull(result);
assertEquals("Get a wrong request operation name", "greet", result.getMethodName());
assertEquals("Get a wrong request parameter size", 2, result.getParameterCount());
assertEquals("Get a wrong request parameter", 2, result.getParameter(1));
assertMockEndpointsSatisfied();
}
use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class XmlRpcDataFormatTest method testRequestMessageFromList.
@Test
public void testRequestMessageFromList() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:request");
mock.expectedMessageCount(1);
Object[] body = new Object[] { "you", 2 };
XmlRpcRequest result = template.requestBodyAndHeader("direct:request", body, XmlRpcConstants.METHOD_NAME, "greet", XmlRpcRequest.class);
assertNotNull(result);
assertEquals("Get a wrong request operation name", "greet", result.getMethodName());
assertEquals("Get a wrong request parameter size", 2, result.getParameterCount());
assertEquals("Get a wrong request parameter", 2, result.getParameter(1));
assertMockEndpointsSatisfied();
}
use of org.apache.xmlrpc.XmlRpcRequest in project wildfly-camel by wildfly-extras.
the class XmlRpcIntegrationTest method testRequestMessage.
@Test
public void testRequestMessage() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
XmlRpcDataFormat request = new XmlRpcDataFormat();
request.setRequest(true);
from("direct:request").marshal(request).to("log:marshalRequestMessage").unmarshal(request).to("log:unmarshalRequestMessage").to("mock:request");
}
});
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
MockEndpoint mock = camelctx.getEndpoint("mock:request", MockEndpoint.class);
mock.expectedMessageCount(1);
XmlRpcRequest result = template.requestBody("direct:request", new XmlRpcRequestImpl("greet", new Object[] { "you", 2 }), XmlRpcRequest.class);
Assert.assertNotNull(result);
Assert.assertEquals("Get a wrong request operation name", "greet", result.getMethodName());
Assert.assertEquals("Get a wrong request parameter size", 2, result.getParameterCount());
Assert.assertEquals("Get a wrong request parameter", 2, result.getParameter(1));
mock.assertIsSatisfied();
} finally {
camelctx.stop();
}
}
Aggregations