org.apache.axis2.addressing.EndpointReference Java Examples
The following examples show how to use
org.apache.axis2.addressing.EndpointReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RetrieveB.java From openxds with Apache License 2.0 | 6 votes |
private OMElement call(OMElement metadata_ele, String endpoint) throws XdsWSException, XdsException, AxisFault { Options options = new Options(); options.setTo(new EndpointReference(endpoint)); // this sets the location of MyService service ServiceClient serviceClient = new ServiceClient(); serviceClient.setOptions(options); OMElement result; Soap soap = new Soap(); soap.setAsync(async); soap.soapCall(metadata_ele, null, //Protocol endpoint, true, // mtom true, // addressing soap12, // soap12 getRequestAction(), getResponseAction()); result = soap.getResult(); return result; }
Example #2
Source File: AxisOperationClient.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * creating the message context of the soap message * * @param addUrl * @param trpUrl * @param action */ private void setMessageContext(String addUrl, String trpUrl, String action) { outMsgCtx = new MessageContext(); //assigning message context’s option object into instance variable Options options = outMsgCtx.getOptions(); options.setTimeOutInMilliSeconds(ClientUtils.getReadTimeout()); //setting properties into option if (trpUrl != null && !"null".equals(trpUrl)) { options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl); } if (addUrl != null && !"null".equals(addUrl)) { options.setTo(new EndpointReference(addUrl)); } if (action != null && !"null".equals(action)) { options.setAction(action); } }
Example #3
Source File: WSEventDispatcher.java From carbon-commons with Apache License 2.0 | 6 votes |
protected synchronized void sendNotification(OMElement topicHeader, OMElement tenantDomainHeader, OMElement payload, String endpoint) throws AxisFault { // The parameter args is used as a mechanism to pass any argument into this method, which // is used by the implementations that extend the behavior of the default Carbon Event // Dispatcher. ConfigurationContextService configurationContextService = WSEventBrokerHolder.getInstance().getConfigurationContextService(); ServiceClient serviceClient = new ServiceClient(configurationContextService.getClientConfigContext(), null); Options options = new Options(); options.setTo(new EndpointReference(endpoint)); options.setAction(EventingConstants.WSE_PUBLISH); serviceClient.setOptions(options); serviceClient.addHeader(topicHeader); if (tenantDomainHeader != null){ serviceClient.addHeader(tenantDomainHeader); } serviceClient.fireAndForget(payload); }
Example #4
Source File: ParallelRequestHelper.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * constructor for parallel request helper * we can use this for the initial begin boxcarring request as well.(sending sessionCookie null) * * @param sessionCookie * @param operation * @param payload * @param serviceEndPoint * @throws org.apache.axis2.AxisFault */ public ParallelRequestHelper(String sessionCookie, String operation, OMElement payload, String serviceEndPoint) throws AxisFault { this.payload = payload; sender = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(serviceEndPoint)); options.setProperty("__CHUNKED__", Boolean.FALSE); options.setTimeOutInMilliSeconds(45000L); options.setAction("urn:" + operation); sender.setOptions(options); if (sessionCookie != null && !sessionCookie.isEmpty()) { Header header = new Header("Cookie", sessionCookie); ArrayList headers = new ArrayList(); headers.add(header); sender.getOptions().setProperty(HTTPConstants.HTTP_HEADERS, headers); } }
Example #5
Source File: Sample700TestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Store test case ") public void messageStoringTest() throws Exception { // The count should be 0 as soon as the message store is created Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Message store should be initially empty"); // refer within a sequence through a store mediator, mediate messages // and verify the messages are stored correctly in the store. ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(getBackEndServiceUrl("SimpleStockQuoteService"))); options.setAction("urn:placeOrder"); options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL()); serviceClient.setOptions(options); serviceClient.sendRobust(createPayload()); Thread.sleep(30000); Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 1, "Messages are missing or repeated"); }
Example #6
Source File: Sample701TestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Sampling Processor " + "test case") public void messageStoreFIXStoringTest() throws Exception { // The count should be 0 as soon as the message store is created Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Message store should be initially empty"); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(getBackEndServiceUrl("StockQuoteProxy"))); options.setAction("urn:placeOrder"); options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL()); serviceClient.setOptions(options); for (int i = 0; i < 10; i++) { serviceClient.sendRobust(createPayload()); } Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) > 0, "Messages are not stored"); }
Example #7
Source File: Sample702TestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Forwarding Processor " + "test case") public void messageStoringTest() throws Exception { // The count should be 0 as soon as the message store is created Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Message store should be initially empty"); // refer within a sequence through a store mediator, mediate messages // and verify the messages are stored correctly in the store. ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(getBackEndServiceUrl("SimpleStockQuoteService"))); options.setAction("urn:placeOrder"); options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL()); serviceClient.setOptions(options); serviceClient.sendRobust(createPayload()); Thread.sleep(30000); Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Messages are not forwarded"); }
Example #8
Source File: Sample704TestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "RESTful Invocations with Message Forwarding" + " Processor test case") public void messageStoreFIXStoringTest() throws Exception { ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(getBackEndServiceUrl("StockQuoteProxy"))); options.setAction("urn:placeOrder"); options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL()); serviceClient.setOptions(options); for (int i = 0; i < 10; i++) { serviceClient.sendRobust(createPayload()); } Thread.sleep(2000); Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Messages are stored"); }
Example #9
Source File: ESBJAVA4909MultipartRelatedTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException { final String EXPECTED = "<m0:uploadFileUsingMTOMResponse xmlns:m0=\"http://services.samples\"><m0:response>" + "<m0:image>PHByb3h5PkFCQzwvcHJveHk+</m0:image></m0:response></m0:uploadFileUsingMTOMResponse>"; OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingMTOM"); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); OMElement response = serviceClient.sendReceive(payload); Assert.assertTrue(response.toString().contains(EXPECTED), "Attachment is missing in the response"); }
Example #10
Source File: TenantAwareLoadBalanceEndpoint.java From attic-stratos with Apache License 2.0 | 6 votes |
/** * @param to get an endpoint to send the information * @param member The member to which an EP has to be created * @param synCtx synapse context * @return the created endpoint */ private Endpoint getEndpoint(EndpointReference to, org.apache.axis2.clustering.Member member, MessageContext synCtx) { AddressEndpoint endpoint = new AddressEndpoint(); endpoint.setEnableMBeanStats(false); endpoint.setName("DLB:" + member.getHostName() + ":" + member.getPort() + ":" + UUID.randomUUID()); EndpointDefinition definition = new EndpointDefinition(); definition.setTimeoutAction(SynapseConstants.DISCARD_AND_FAULT); definition.setTimeoutDuration(LoadBalancerConfiguration.getInstance().getEndpointTimeout()); definition.setReplicationDisabled(true); definition.setAddress(to.getAddress()); endpoint.setDefinition(definition); endpoint.init((SynapseEnvironment) ((Axis2MessageContext) synCtx).getAxis2MessageContext(). getConfigurationContext().getAxisConfiguration(). getParameterValue(SynapseConstants.SYNAPSE_ENV)); return endpoint; }
Example #11
Source File: SOAPClient.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Sends a SOAP message with MTOM attachment and returns response as a OMElement. * * @param fileName name of file to be sent as an attachment * @param targetEPR service url * @param soapAction SOAP Action to set. Specify with "urn:" * @return OMElement response from BE service * @throws AxisFault in case of an invocation failure */ public OMElement sendSOAPMessageWithAttachment(String fileName, String targetEPR, String soapAction) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction(soapAction); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); return serviceClient.sendReceive(payload); }
Example #12
Source File: SecurityHandlerAdapterTest.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Tests a handler configuration similar to the following with no resources defined. * <p> * <handler name="SampleInternalApiHandlerWithNoResources" * class="internal.http.api.SampleInternalApiHandlerWithNoResources"/> */ @Test public void testHandledWithNoResource() { //set message context MessageContext messageContext = new TestMessageContext(); EndpointReference endpointReference = new EndpointReference(); endpointReference.setAddress("/sectest/resource1"); messageContext.setTo(endpointReference); TestSecurityHandler internalAPIHandler = new TestSecurityHandler("/sectest"); //test with no resources internalAPIHandler.setResources(new ArrayList<>()); internalAPIHandler.invoke(messageContext); Assert.assertTrue("Handler should be engaged when no resources are explictely defined, but it was not engaged.", internalAPIHandler.isHandleTriggered()); }
Example #13
Source File: AuthenticateStub.java From product-es with Apache License 2.0 | 6 votes |
public static Stub authenticateStub(Stub stub, String sessionCookie, String backendURL) { long soTimeout = 5 * 60 * 1000; // Three minutes ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setTimeOutInMilliSeconds(soTimeout); System.out.println("XXXXXXXXXXXXXXXXXXX" + backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", "")); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, sessionCookie); option.setTo(new EndpointReference(backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", ""))); if (log.isDebugEnabled()) { log.debug("AuthenticateStub : Stub created with session " + sessionCookie); } return stub; }
Example #14
Source File: AuthenticateStub.java From micro-integrator with Apache License 2.0 | 6 votes |
public static Stub authenticateStub(Stub stub, String sessionCookie, String backendURL) { long soTimeout = 5 * 60 * 1000; // Three minutes ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setTimeOutInMilliSeconds(soTimeout); System.out.println("XXXXXXXXXXXXXXXXXXX" + backendURL + client.getServiceContext().getAxisService().getName() .replaceAll("[^a-zA-Z]", "")); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, sessionCookie); option.setTo(new EndpointReference( backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", ""))); if (log.isDebugEnabled()) { log.debug("AuthenticateStub : Stub created with session " + sessionCookie); } return stub; }
Example #15
Source File: Util.java From carbon-commons with Apache License 2.0 | 6 votes |
public static String getWsdlInformation(String serviceName, AxisConfiguration axisConfig) throws AxisFault { String ip; try { ip = NetworkUtils.getLocalHostname(); } catch (SocketException e) { throw new AxisFault("Cannot get local host name", e); } TransportInDescription transportInDescription = axisConfig.getTransportIn("http"); if (transportInDescription == null) { transportInDescription = axisConfig.getTransportIn("https"); } if (transportInDescription != null) { EndpointReference[] epr = transportInDescription.getReceiver().getEPRsForService(serviceName, ip); String wsdlUrlPrefix = epr[0].getAddress(); if (wsdlUrlPrefix.endsWith("/")) { wsdlUrlPrefix = wsdlUrlPrefix.substring(0, wsdlUrlPrefix.length() - 1); } return wsdlUrlPrefix + "?wsdl"; } return null; }
Example #16
Source File: SOAPClient.java From product-ei with Apache License 2.0 | 6 votes |
/** * Sends a SOAP message with MTOM attachment and returns response as a OMElement. * * @param fileName name of file to be sent as an attachment * @param targetEPR service url * @param soapAction SOAP Action to set. Specify with "urn:" * @return OMElement response from BE service * @throws AxisFault in case of an invocation failure */ public OMElement sendSOAPMessageWithAttachment(String fileName, String targetEPR, String soapAction) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction(soapAction); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); return serviceClient.sendReceive(payload); }
Example #17
Source File: ESBJAVA4909MultipartRelatedTestCase.java From product-ei with Apache License 2.0 | 6 votes |
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException { final String EXPECTED = "<m0:uploadFileUsingMTOMResponse xmlns:m0=\"http://services.samples\"><m0:response>" + "<m0:image>PHByb3h5PkFCQzwvcHJveHk+</m0:image></m0:response></m0:uploadFileUsingMTOMResponse>"; OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingMTOM"); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); OMElement response = serviceClient.sendReceive(payload); Assert.assertTrue(response.toString().contains(EXPECTED), "Attachment is missing in the response"); }
Example #18
Source File: Sample701TestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Sampling Processor " + "test case") public void messageStoreFIXStoringTest() throws Exception { // The count should be 0 as soon as the message store is created Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Message store should be initially empty"); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(getBackEndServiceUrl("StockQuoteProxy"))); options.setAction("urn:placeOrder"); options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL()); serviceClient.setOptions(options); for (int i = 0; i < 10; i++) { serviceClient.sendRobust(createPayload()); } Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) > 0, "Messages are not stored"); }
Example #19
Source File: Sample700TestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Store test case ") public void messageStoringTest() throws Exception { // The count should be 0 as soon as the message store is created Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Message store should be initially empty"); // refer within a sequence through a store mediator, mediate messages // and verify the messages are stored correctly in the store. ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(getBackEndServiceUrl("SimpleStockQuoteService"))); options.setAction("urn:placeOrder"); options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL()); serviceClient.setOptions(options); serviceClient.sendRobust(createPayload()); Thread.sleep(30000); Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 1, "Messages are missing or repeated"); }
Example #20
Source File: AxisOperationClient.java From product-ei with Apache License 2.0 | 6 votes |
/** * creating the message context of the soap message * * @param addUrl * @param trpUrl * @param action */ private void setMessageContext(String addUrl, String trpUrl, String action) { outMsgCtx = new MessageContext(); //assigning message context’s option object into instance variable Options options = outMsgCtx.getOptions(); //setting properties into option if (trpUrl != null && !"null".equals(trpUrl)) { options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl); } if (addUrl != null && !"null".equals(addUrl)) { options.setTo(new EndpointReference(addUrl)); } if(action != null && !"null".equals(action)) { options.setAction(action); } }
Example #21
Source File: AuthenticateStub.java From product-ei with Apache License 2.0 | 6 votes |
public static Stub authenticateStub(Stub stub, String sessionCookie, String backendURL) { long soTimeout = 5 * 60 * 1000; // Three minutes ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setTimeOutInMilliSeconds(soTimeout); System.out.println("XXXXXXXXXXXXXXXXXXX" + backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", "")); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, sessionCookie); option.setTo(new EndpointReference(backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", ""))); if (log.isDebugEnabled()) { log.debug("AuthenticateStub : Stub created with session " + sessionCookie); } return stub; }
Example #22
Source File: RequestSender.java From product-ei with Apache License 2.0 | 6 votes |
public void sendRequest(String eprUrl, String operation, String payload, int numberOfInstances, List<String> expectedStrings, boolean twoWay) throws Exception { waitForProcessDeployment(eprUrl); // assert !this.isServiceAvailable(eprUrl) : "Service not found"; for (int i = 0; i < numberOfInstances; i++) { EndpointReference epr = new EndpointReference(eprUrl + "/" + operation); if (twoWay) { OMElement result = this.sendRequest(payload, epr); if (expectedStrings != null) { for (String expectedString : expectedStrings) { Assert.assertFalse(!result.toString().contains(expectedString)); } } } else { this.sendRequestOneWay(payload, epr); } } }
Example #23
Source File: SecurityHandlerAdapterTest.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Tests a handler configuration similar to the following. * * <handler name="SampleInternalApiHandlerWithAllResources" * class="internal.http.api.SampleInternalApiHandlerWithAllResources"> * <resources> * <resource>/</resource> * </resources> *</handler> */ @Test public void testHandledWithAllResources() { //Create test message context MessageContext messageContext = new TestMessageContext(); EndpointReference endpointReference = new EndpointReference(); messageContext.setTo(endpointReference); TestSecurityHandler internalAPIHandler = new TestSecurityHandler("/sectest"); List<String> resources = new ArrayList<>(); resources.add("/"); internalAPIHandler.setResources(resources); //set message context with matching resource endpointReference.setAddress("/sectest/resource1"); internalAPIHandler.invoke(messageContext); Assert.assertTrue("Handler should be engaged since all resources are defined, but it was not engaged.", internalAPIHandler.isHandleTriggered()); }
Example #24
Source File: UtilsTestCase.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testSetSOAPFault() { SOAPEnvelope soapEnvelope = Mockito.mock(SOAPEnvelope.class); SOAPHeader soapHeader = Mockito.mock(SOAPHeader.class); Iterator iterator = Mockito.mock(Iterator.class); OMNode soapHeaderBlock = Mockito.mock(OMNode.class); Mockito.when(messageContext.getMessageID()).thenReturn("123"); Mockito.when(messageContext.getEnvelope()).thenReturn(soapEnvelope); Mockito.when(soapEnvelope.getHeader()).thenReturn(soapHeader); Mockito.when(soapHeader.examineAllHeaderBlocks()).thenReturn(iterator); Mockito.when(iterator.hasNext()).thenReturn(true, false); // Mockito.when(iterator.next()).thenReturn(omelement); Mockito.when(iterator.next()).thenReturn(soapHeaderBlock); Utils.setSOAPFault(messageContext, "", "code", "detail"); Assert.assertTrue(true); // No error has occurred. hence test passes. //when messageContext.isSOAP11() is true Mockito.when(messageContext.isSOAP11()).thenReturn(true); Utils.setSOAPFault(messageContext, "", "code", "detail"); Assert.assertTrue(true); // No error has occurred. hence test passes. // when messageContext.getFaultTo() != null EndpointReference endpointReference = Mockito.mock(EndpointReference.class); Mockito.when(messageContext.getFaultTo()).thenReturn(endpointReference); Utils.setSOAPFault(messageContext, "", "code", "detail"); Assert.assertTrue(true); // No error has occurred. hence test passes. // when messageContext.getFaultTo() != null Mockito.when(messageContext.getFaultTo()).thenReturn(endpointReference); Utils.setSOAPFault(messageContext, "", "code", "detail"); Assert.assertTrue(true); // No error has occurred. hence test passes. }
Example #25
Source File: DiscoveryClient.java From carbon-commons with Apache License 2.0 | 5 votes |
public DiscoveryClient(ConfigurationContext cfgCtx, String proxyURL) throws DiscoveryException { try { serviceClient = new ServiceClient(cfgCtx, null); serviceClient.setTargetEPR(new EndpointReference(proxyURL)); } catch (AxisFault axisFault) { throw new DiscoveryException("Error while initializing the WS-Discovery client", axisFault); } }
Example #26
Source File: LoadBalanceSessionFullClient.java From product-ei with Apache License 2.0 | 5 votes |
private void updateServiceClientOptions(String trpUrl, String addUrl, String prxUrl) throws AxisFault { Options options = new Options(); options.setTo(new EndpointReference(trpUrl)); options.setAction("urn:sampleOperation"); options.setTimeOutInMilliSeconds(10000000); // 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); } else { serviceClient.engageModule("addressing"); } serviceClient.engageModule("addressing"); if (prxUrl != null && !"null".equals(prxUrl)) { HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties(); try { URL url = new URL(prxUrl); proxyProperties.setProxyName(url.getHost()); proxyProperties.setProxyPort(url.getPort()); proxyProperties.setUserName(""); proxyProperties.setPassWord(""); proxyProperties.setDomain(""); options.setProperty(HTTPConstants.PROXY, proxyProperties); } catch (MalformedURLException e) { String msg = "Error while creating proxy URL"; log.error(msg, e); throw new AxisFault(msg, e); } } serviceClient.setOptions(options); }
Example #27
Source File: LoadBalanceSessionFullClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private void updateServiceClientOptions(String trpUrl, String addUrl, String prxUrl) throws AxisFault { Options options = new Options(); options.setTo(new EndpointReference(trpUrl)); options.setAction("urn:sampleOperation"); options.setTimeOutInMilliSeconds(10000000); // 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); } else { serviceClient.engageModule("addressing"); } serviceClient.engageModule("addressing"); if (prxUrl != null && !"null".equals(prxUrl)) { HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties(); try { URL url = new URL(prxUrl); proxyProperties.setProxyName(url.getHost()); proxyProperties.setProxyPort(url.getPort()); proxyProperties.setUserName(""); proxyProperties.setPassWord(""); proxyProperties.setDomain(""); options.setProperty(HTTPConstants.PROXY, proxyProperties); } catch (MalformedURLException e) { String msg = "Error while creating proxy URL"; log.error(msg, e); throw new AxisFault(msg, e); } } serviceClient.setOptions(options); }
Example #28
Source File: AxisServiceClientUtils.java From product-ei with Apache License 2.0 | 5 votes |
public static void sendRequest(String eprUrl, String operation, String payload, int numberOfInstances, String expectedException, boolean twoWay) throws XMLStreamException, AxisFault { assertFalse(!AxisServiceClientUtils.isServiceAvailable(eprUrl)); for (int i = 0; i < numberOfInstances; i++) { try { EndpointReference epr = new EndpointReference(operation); if (twoWay) { OMElement result = AxisServiceClientUtils.sendRequest(payload, epr); fail("Exception expected!!! : " + result.toString()); } else { AxisServiceClientUtils.sendRequestOneWay(payload, epr); } } catch (XMLStreamException e) { if (!e.getClass().getSimpleName().equals(expectedException)) { throw new XMLStreamException(e); } } catch (AxisFault axisFault) { if (!axisFault.getClass().getSimpleName().equals(expectedException)) { throw new AxisFault(axisFault.getMessage()); } } if (expectedException != null) { fail("Exception expected. But not found!!"); } } }
Example #29
Source File: AxisServiceClientUtils.java From product-ei with Apache License 2.0 | 5 votes |
public static void sendRequest(String eprUrl, String operation, String payload, int numberOfInstances, List<String> expectedStrings, boolean twoWay) throws Exception { waitForServiceDeployment(eprUrl); assertFalse(!AxisServiceClientUtils.isServiceAvailable(eprUrl)); for (int i = 0; i < numberOfInstances; i++) { try { EndpointReference epr = new EndpointReference(eprUrl + "/" + operation); if (twoWay) { OMElement result = AxisServiceClientUtils.sendRequest(payload, epr); if (expectedStrings != null) { for (String expectedString : expectedStrings) { assertFalse(!result.toString() .contains(expectedString)); } } } else { AxisServiceClientUtils.sendRequestOneWay(payload, epr); } } catch (XMLStreamException e) { log.error(e); throw new XMLStreamException("cannot read xml stream " + e); } catch (AxisFault axisFault) { log.error(axisFault.getMessage()); throw new AxisFault("cannot read xml stream " + axisFault.getMessage()); } } }
Example #30
Source File: EventBrokerAdminClient.java From product-ei with Apache License 2.0 | 5 votes |
public void publish(String topic, OMElement element) throws AxisFault { log.debug("published element to "+ topic ); EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, backendUrl +"/publish/"+topic); configureCookie(service._getServiceClient()); ServiceClient serviceClient = service._getServiceClient(); OMElement header = omFactory.createOMElement(new QName(TOPIC_HEADER_NS, TOPIC_HEADER_NAME)); header.setText(topic); serviceClient.addHeader(header); serviceClient.getOptions().setTo(new EndpointReference(backendUrl+"/publish")); //serviceClient.getOptions().setTo(new EndpointReference(brokerUrl)); serviceClient.getOptions().setAction("urn:publish"); serviceClient.sendRobust(element); }