use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.
the class HttpTransportTestSuiteBuilder method build.
public void build() {
TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
builder.addEnvironment(tdf);
HttpChannel channel = new HttpChannel();
builder.addAsyncChannel(channel);
builder.addByteArrayAsyncTestClient(new JavaNetClient());
if (axisTestClientConfigurators.isEmpty()) {
builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
} else {
for (AxisTestClientConfigurator configurator : axisTestClientConfigurators) {
builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), configurator);
}
}
builder.addRESTAsyncTestClient(new JavaNetRESTClient());
builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
builder.addByteArrayAsyncEndpoint(new JettyByteArrayAsyncEndpoint());
builder.addRESTAsyncEndpoint(new JettyRESTAsyncEndpoint());
builder.addRequestResponseChannel(channel);
builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient());
builder.addEchoEndpoint(new AxisEchoEndpoint());
builder.addEchoEndpoint(new JettyEchoEndpoint());
builder.build();
suite.addTest(new MinConcurrencyTest(new AsyncChannel[] { new HttpChannel(), new HttpChannel() }, 2, false, tdf));
}
use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.
the class RabbitMQUtils method getBuilder.
private static Builder getBuilder(MessageContext msgContext, String rawContentType) throws AxisFault {
try {
ContentType contentType = new ContentType(rawContentType);
String charset = contentType.getParameter("charset");
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charset);
Builder builder = BuilderUtil.getBuilderFromSelector(contentType.getBaseType(), msgContext);
if (builder == null) {
if (log.isDebugEnabled()) {
log.debug("No message builder found for type '" + contentType.getBaseType() + "'. Falling back to SOAP.");
}
builder = new SOAPBuilder();
}
return builder;
} catch (ParseException e) {
throw new AxisFault("Error parsing content type: " + rawContentType, e);
}
}
use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.
the class MqttUtils method invoke.
public static void invoke(MqttMessage mqttMessage, MessageContext msgContext, String contentType) throws AxisFault, AxisMqttException {
if (contentType == null) {
contentType = "text/plain";
}
Builder builder = BuilderUtil.getBuilderFromSelector(contentType, msgContext);
if (builder == null) {
if (log.isDebugEnabled()) {
log.debug("No message builder found for type '" + contentType + "'. Falling back to SOAP.");
}
builder = new SOAPBuilder();
}
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
OMElement documentElement = null;
byte[] bytes = mqttMessage.getPayload();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
documentElement = builder.processDocument(byteArrayInputStream, contentType, msgContext);
msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
}
use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.
the class MSMQUtil method setSOAPEnvelope.
public static void setSOAPEnvelope(Message message, MessageContext msgContext, String contentType) throws AxisFault {
if (contentType == null) {
// TODO;we only support text/plain
contentType = "text/plain";
if (log.isDebugEnabled()) {
log.debug("No content type specified; assuming " + contentType);
}
}
int index = contentType.indexOf(';');
String type = index > 0 ? contentType.substring(0, index) : contentType;
Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
String messageBody = null;
try {
messageBody = message.getBodyAsString();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (builder == null) {
if (log.isDebugEnabled()) {
log.debug("No message builder found for type' " + type + ".Using SOAP builder");
}
builder = new SOAPBuilder();
}
OMElement documentElement;
// TODO: we need to handle the message types separately. Assume text message builder format
TextMessageBuilder textMessageBuilder;
if (builder instanceof TextMessageBuilder) {
textMessageBuilder = (TextMessageBuilder) builder;
} else {
textMessageBuilder = new TextMessageBuilderAdapter(builder);
}
documentElement = textMessageBuilder.processDocument(messageBody, contentType, msgContext);
msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
}
use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class JsonStreamingBuilderTest method testCase.
public void testCase() throws AxisFault {
String jsonPayload = "{\n" + "\"account_number\":\"1234567890\",\n" + "\"routing_number\":\"09100001\",\n" + "\"image_type\":\"COMMERCIAL_DEPOSIT\"\n" + "}";
String expectedXml = "<jsonObject>" + "<account_number>1234567890</account_number>" + "<routing_number>09100001</routing_number>" + "<image_type>COMMERCIAL_DEPOSIT</image_type>" + "</jsonObject>";
MessageContext messageContext = Util.newMessageContext();
InputStream inputStream = Util.newInputStream(jsonPayload.getBytes());
Builder jsonBuilder = Util.newJsonStreamBuilder();
OMElement element = jsonBuilder.processDocument(inputStream, "application/json", messageContext);
assertEquals("Invalid content received", expectedXml, element.toString());
}
Aggregations