use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class ResponseMessageBuilderTest method testUnsubscriptionResponse.
public void testUnsubscriptionResponse() {
String id = UIDGenerator.generateURNString();
String addressUrl = "http://synapse.test.com/eventing/sunscriptions";
SynapseSubscription sub = new SynapseSubscription();
sub.setId(id);
sub.setSubManUrl(addressUrl);
String expected = "<wse:UnsubscribeResponse xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext("<empty/>", null).getAxis2MessageContext();
ResponseMessageBuilder builder = new ResponseMessageBuilder(msgCtx);
SOAPEnvelope env = builder.genUnSubscribeResponse(sub);
OMElement resultOm = env.getBody().getFirstElement();
OMElement expectedOm = AXIOMUtil.stringToOM(expected);
assertTrue(compare(expectedOm, resultOm));
} catch (Exception e) {
fail("Error while constructing the test message context: " + e.getMessage());
}
}
use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class ResponseMessageBuilderTest method testSubscriptionResponse.
public void testSubscriptionResponse() {
String id = UIDGenerator.generateURNString();
String addressUrl = "http://synapse.test.com/eventing/sunscriptions";
SynapseSubscription sub = new SynapseSubscription();
sub.setId(id);
sub.setSubManUrl(addressUrl);
String expected = "<wse:SubscribeResponse xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">" + "<wse:SubscriptionManager>" + "<wsa:Address xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">" + addressUrl + "</wsa:Address>" + "<wsa:ReferenceParameters xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">" + "<wse:Identifier>" + id + "</wse:Identifier>" + "</wsa:ReferenceParameters>" + "</wse:SubscriptionManager>" + "</wse:SubscribeResponse>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext("<empty/>", null).getAxis2MessageContext();
ResponseMessageBuilder builder = new ResponseMessageBuilder(msgCtx);
SOAPEnvelope env = builder.genSubscriptionResponse(sub);
OMElement resultOm = env.getBody().getFirstElement();
OMElement expectedOm = AXIOMUtil.stringToOM(expected);
assertTrue(compare(expectedOm, resultOm));
} catch (Exception e) {
fail("Error while constructing the test message context: " + e.getMessage());
}
}
use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.
the class StockQuoteSampleClient method init.
private void init(String addUrl, String trpUrl, String prxUrl, String policyKey, long timeout) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Initializing sample Axis2 client");
}
configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientConfig.getClientRepo(), clientConfig.getAxis2Xml());
serviceClient = new ServiceClient(configContext, null);
Options options = new Options();
if (addUrl != null && !"".equals(addUrl)) {
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
}
if (trpUrl != null && !"".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
}
if (prxUrl != 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);
}
if (policyKey != null && !"".equals(policyKey)) {
log.info("Using WS-Security");
serviceClient.engageModule("addressing");
serviceClient.engageModule("rampart");
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(policyKey));
Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
}
if (timeout > 0) {
log.info("setting client timeout to: " + timeout);
options.setTimeOutInMilliSeconds(timeout);
}
options.setProperty(HTTPConstants.HTTP_HEADERS, httpHeaders);
serviceClient.setOptions(options);
}
use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.
the class RabbitMQUtils method setSOAPEnvelope.
public static void setSOAPEnvelope(RabbitMQMessage message, MessageContext msgContext, String contentType) throws AxisFault {
int index = contentType.indexOf(';');
String type = index > 0 ? contentType.substring(0, index) : contentType;
Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
if (builder == null) {
if (log.isDebugEnabled()) {
log.debug("No message builder found for type '" + type + "'. Falling back to SOAP.");
}
builder = new SOAPBuilder();
}
OMElement documentElement;
String charSetEnc = null;
try {
if (contentType != null) {
charSetEnc = new ContentType(contentType).getParameter("charset");
}
} catch (ParseException ex) {
log.debug("Parse error", ex);
}
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
documentElement = builder.processDocument(new ByteArrayInputStream(message.getBody()), contentType, msgContext);
msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
}
use of org.apache.axis2.builder.Builder in project carbon-business-process by wso2.
the class ServiceConfigurationUtil method configureService.
public static void configureService(AxisService axisService, EndpointConfiguration endpointConf, ConfigurationContext configCtx) throws AxisFault {
if (endpointConf != null && endpointConf.isServiceDescriptionAvailable() && StringUtils.isNotEmpty(endpointConf.getServiceDescriptionLocation())) {
OMElement documentEle = getServiceElement(endpointConf);
if (documentEle != null) {
if (log.isDebugEnabled()) {
log.debug("Configuring service " + axisService.getName() + " using: " + endpointConf.getServiceDescriptionLocation());
}
ServiceBuilder builder = new ServiceBuilder(configCtx, axisService);
Iterator itr = documentEle.getChildElements();
while (itr.hasNext()) {
OMElement serviceEle = (OMElement) itr.next();
if (serviceEle.getLocalName().toLowerCase().equals("service")) {
if (serviceEle.getAttribute(new QName("name")) != null && serviceEle.getAttribute(new QName("name")).getAttributeValue().equals(axisService.getName())) {
builder.populateService(serviceEle);
// This is a hack to avoid security configurations get persisted when we configure using
// services.xml file or policy.xml file BPEL package. But this should be fix at the
// Carbon Persistence manager.
Parameter param = new Parameter(BusinessProcessConstants.CONFIGURED_USING_BPEL_PKG_CONFIG_FILES, "true");
axisService.addParameter(param);
}
}
}
}
}
}
Aggregations