org.apache.axis2.AxisFault Java Examples
The following examples show how to use
org.apache.axis2.AxisFault.
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: SendMailWithBCCThroughESBTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "Test email sender with BCC ") public void testEmailTransport() throws ESBMailTransportIntegrationTestException, XMLStreamException, AxisFault, MessagingException { Date date = new Date(); String message = "Send Mail With BCC" + new Timestamp(date.getTime()); AxisServiceClient axisServiceClient = new AxisServiceClient(); OMElement request = AXIOMUtil.stringToOM( " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body>\n" + " <emailSubject> Subject :" + message + "</emailSubject>\n" + " </soapenv:Body>\n" + " </soapenv:Envelope>"); axisServiceClient.sendReceive(request, getProxyServiceURLHttp("MailToTransportSenderBCC"), "mediate"); assertTrue(GreenMailServer.isMailReceived("imap", bccUser, message), "Mail not received"); }
Example #2
Source File: ReScheduleTaskTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
private void IncreaseEmployeeSalary(String employeeNumber) throws AxisFault, InterruptedException { OMElement payload = fac.createOMElement("incrementEmployeeSalary", omNs); OMElement empNo = fac.createOMElement("employeeNumber", omNs); empNo.setText(employeeNumber); payload.addChild(empNo); OMElement salary = fac.createOMElement("increment", omNs); salary.setText("10000"); payload.addChild(salary); new AxisServiceClient().sendRobust(payload, serviceEndPoint, "incrementEmployeeSalary"); OMElement result = getEmployeeById(employeeNumber); Assert.assertTrue(result.toString().contains("<salary>60000.0</salary>"), "Expected Result Mismatched"); }
Example #3
Source File: HL7MessageUtils.java From micro-integrator with Apache License 2.0 | 6 votes |
public static MessageContext createErrorMessageContext(String rawMessage, Exception errorMsg, InboundProcessorParams params) throws AxisFault, HL7Exception { MessageContext synCtx = createSynapseMessageContext( params.getProperties().getProperty(MLLPConstants.HL7_INBOUND_TENANT_DOMAIN)); if (params.getProperties().getProperty(Axis2HL7Constants.HL7_VALIDATION_PASSED) != null) { synCtx.setProperty(Axis2HL7Constants.HL7_VALIDATION_PASSED, params.getProperties().getProperty(Axis2HL7Constants.HL7_VALIDATION_PASSED)); } try { synCtx.setProperty(SynapseConstants.ERROR_CODE, SynapseConstants.RCV_IO_ERROR_RECEIVING); synCtx.setProperty(SynapseConstants.ERROR_MESSAGE, errorMsg.getMessage()); synCtx.setProperty(SynapseConstants.ERROR_DETAIL, (errorMsg.getCause() == null ? "null" : errorMsg.getCause().getMessage())); synCtx.setProperty(SynapseConstants.ERROR_EXCEPTION, errorMsg); synCtx.setEnvelope(createErrorEnvelope(synCtx, rawMessage, errorMsg.getMessage(), params)); } catch (Exception e) { throw new HL7Exception(e); } return synCtx; }
Example #4
Source File: AbstractBinaryDataServiceTest.java From micro-integrator with Apache License 2.0 | 6 votes |
private void storeBinaryData(String id, byte[] data) throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("id", id); params.put("data", new String(Base64.encodeBase64(data), DBConstants.DEFAULT_CHAR_SET_TYPE)); try { TestUtils.checkForService(this.epr); assertNotNull(TestUtils.callOperation(this.epr, "store_binary_data_op", params)); } catch (AxisFault e) { // ignore for now if (!MySQLDMLServiceTest.INCOMING_MESSAGE_IS_NULL_ERROR.equals(e.getReason())) { e.printStackTrace(); throw e; } } }
Example #5
Source File: Soap11FaultCodeVersionMismatchedTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "Creating SOAP1.1 fault code VersionMismatched") public void testSOAP11FaultCodeVersionMismatched() throws AxisFault { try { axis2Client.sendSimpleStockQuoteRequest( getMainSequenceURL(), null, "WSO2"); fail("This query must throw an exception."); } catch (AxisFault expected) { log.info("Fault Message : " + expected.getMessage()); assertEquals(expected.getReason(), "Soap11FaultCodeVersionMismatchedTestCase", "Fault Reason Mismatched"); assertEquals(expected.getFaultCode().getLocalPart(), "VersionMismatch", "Fault code value mismatched"); assertEquals(expected.getFaultCode().getPrefix(), "soap11Env", "Fault code prefix mismatched"); } }
Example #6
Source File: SOAPEntitlementServiceClient.java From micro-integrator with Apache License 2.0 | 6 votes |
private EntitledAttributesDTO[] getEntitledAttributes(String subjectName, String resourceName, String subjectId, String action, boolean enableChildSearch, EntitlementServiceStub stub, Authenticator authenticator) throws Exception { EntitledResultSetDTO results; try { results = stub.getEntitledAttributes(subjectName, resourceName, subjectId, action, enableChildSearch); } catch (AxisFault e) { if (ProxyConstants.SESSION_TIME_OUT.equals(e.getFaultCode().getLocalPart())) { setAuthCookie(true, stub, authenticator); results = stub.getEntitledAttributes(subjectName, resourceName, subjectId, action, enableChildSearch); } else { throw e; } } return results.getEntitledAttributesDTOs(); }
Example #7
Source File: FaultHandler.java From carbon-commons with Apache License 2.0 | 6 votes |
private void updateStatistics(MessageContext msgContext) throws AxisFault { // Process System Request count Parameter globalRequestCounter = msgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER); ((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet(); // Increment the global fault count Parameter globalFaultCounter = msgContext.getParameter(StatisticsConstants.GLOBAL_FAULT_COUNTER); ((AtomicInteger) globalFaultCounter.getValue()).incrementAndGet(); updateCurrentInvocationGlobalStatistics(msgContext); // Calculate response times ResponseTimeCalculator.calculateResponseTimes(msgContext); }
Example #8
Source File: ESBJAVA5135ResponseBodyWith202TestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Test response with 202 and body is built by ESB and responds client * * @throws AxisFault in case of an axis2 level issue when sending * @throws MalformedURLException in case of url is malformed * @throws AutomationFrameworkException in case of any other test suite level issue */ @Test(groups = "wso2.esb", description = "Test response with 202 and body is built by ESB and responds client " + "properly") public void testResponseWith202() throws AxisFault, MalformedURLException, AutomationFrameworkException { Map<String, String> requestHeader = new HashMap<>(); requestHeader.put("Content-type", "text/xml"); requestHeader.put("SOAPAction", "urn:mediate"); String message = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap" + ".org/soap/envelope/\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body/>\n" + "</soapenv:Envelope>"; HttpResponse response = HttpRequestUtil. doPost(new URL(getProxyServiceURLHttp("mockProxy")), message, requestHeader); Assert.assertTrue(response.getData().contains("Hello World"), "Expected response was not" + " received. Got " + response.getData()); }
Example #9
Source File: ListMetaDataServiceClient.java From product-es with Apache License 2.0 | 5 votes |
public ListMetaDataServiceClient(String backEndUrl, String userName, String password) throws RemoteException { this.endPoint = backEndUrl + serviceName; try { listMetadataServiceStub = new ListMetadataServiceStub(endPoint); } catch (AxisFault axisFault) { log.error("Error on initializing listMetadataServiceStub : " + axisFault.getMessage()); throw new RemoteException("Error on initializing listMetadataServiceStub : ", axisFault); } AuthenticateStub.authenticateStub(userName, password, listMetadataServiceStub); }
Example #10
Source File: Soap11FaultCodeMustUnderstandTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.esb" }, description = "Creating SOAP1.1 fault code MustUnderstand") public void testSOAP11FaultCodeMustUnderstand() throws AxisFault { String proxyServiceName = "Soap11FaultCodeMustUnderstandTestCaseProxy"; try { axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp(proxyServiceName), null, "WSO2"); fail("This query must throw an exception."); } catch (AxisFault expected) { log.info("Fault Message : " + expected.getMessage()); assertEquals(expected.getReason(), "Soap11FaultCodeMustUnderstandTestCase", "Fault Reason Mismatched"); assertEquals(expected.getFaultCode().getLocalPart(), "MustUnderstand", "Fault code value mismatched"); assertEquals(expected.getFaultCode().getPrefix(), "soap11Env", "Fault code prefix mismatched"); } }
Example #11
Source File: AxisServiceClientUtils.java From micro-integrator with Apache License 2.0 | 5 votes |
public static void sendRequestOneWay(String payloadStr, EndpointReference targetEPR) throws XMLStreamException, AxisFault { OMElement payload = AXIOMUtil.stringToOM(payloadStr); Options options = new Options(); options.setTo(targetEPR); //options.setAction("urn:" + operation); //since soapAction = "" //Blocking invocation ServiceClient sender = new ServiceClient(); sender.setOptions(options); sender.fireAndForget(payload); }
Example #12
Source File: SAMLSSOValidatorServiceClient.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * Build response for configuration * * @param issuer * @param userName * @return encoded & XML response * @throws AxisFault */ public GeneratedResponseDTO buildResponse(String issuer, String userName) throws AxisFault { try { return stub.buildResponse(issuer, userName); } catch (RemoteException e) { log.error("Error building response", e); throw new AxisFault(e.getMessage(), e); } }
Example #13
Source File: RegexTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.dss", description = "Invoking insert operation to verify regex support") public void performInsertQueryWithQMarks() throws XPathExpressionException, AxisFault { OMElement payload = factory.createOMElement("insert", omNs); OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "insert"); boolean name = "SUCCESSFUL".equals(result.getText()); Assert.assertTrue(name, "insert query testing with question marks is failed"); }
Example #14
Source File: ParameterUtil.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Create an Axis2 parameter based on key and value. * * @param name * @param value * @return Parameter * @throws AxisFault */ public static Parameter createParameter(String name, String value) throws AxisFault { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace ns = fac.createOMNamespace("", ""); OMElement paramEle = fac.createOMElement("parameter", ns); if (name == null) { throw new AxisFault("Parameter name is madatory."); } paramEle.addAttribute("name", name, ns); if (value != null && value.length() != 0) { paramEle.setText(value); } return createParameter(paramEle); }
Example #15
Source File: SwaggerGenerator.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Update the response with provided response string. * * @param response CarbonHttpResponse which will be updated * @param responseString String response to be updated in response * @param contentType Content type of the response to be updated in response headaers * @throws Exception Any exception occured during the update */ protected void updateResponse(CarbonHttpResponse response, String responseString, String contentType) throws AxisFault { try { ((BlobOutputStream) response.getOutputStream()).getBlob().readFrom(new ByteArrayInputStream (responseString.getBytes(SwaggerConstants.DEFAULT_ENCODING)), responseString.length()); } catch (StreamCopyException streamCopyException) { handleException("Error in generating Swagger definition : failed to copy data to response ", streamCopyException); } catch (UnsupportedEncodingException encodingException) { handleException("Error in generating Swagger definition : exception in encoding ", encodingException); } response.setStatus(SwaggerConstants.HTTP_OK); response.getHeaders().put(HTTP.CONTENT_TYPE, contentType); }
Example #16
Source File: LoadbalanceFailoverClient.java From product-ei with Apache License 2.0 | 5 votes |
/** * This method is used to send a single request to the load balancing service * @param proxyURL will be the location where load balancing proxy or sequence is defined. * @param serviceURL will be the URL for LBService * @return the response * @throws org.apache.axis2.AxisFault */ public String sendLoadBalanceRequest(String proxyURL,String serviceURL,String clientTimeoutInMilliSeconds) throws AxisFault { OMFactory fac = OMAbstractFactory.getOMFactory(); OMElement value = fac.createOMElement("Value", null); value.setText("Sample string"); Options options = new Options(); if (proxyURL != null && !"null".equals(proxyURL)) { options.setTo(new EndpointReference(proxyURL)); } options.setAction("urn:sampleOperation"); long timeout = Integer.parseInt(getProperty("timeout", clientTimeoutInMilliSeconds)); System.out.println("timeout=" + timeout); options.setTimeOutInMilliSeconds(timeout); if (serviceURL != null && !"null".equals(serviceURL)) { // set addressing, transport and proxy url serviceClient.engageModule("addressing"); options.setTo(new EndpointReference(serviceURL)); } serviceClient.setOptions(options); serviceClient.getOptions().setManageSession(true); OMElement responseElement = serviceClient.sendReceive(value); String response = responseElement.getText(); return response; }
Example #17
Source File: EntitlementAdminServiceClient.java From carbon-identity with Apache License 2.0 | 5 votes |
public void refreshAttributeFinder(String finderName) throws AxisFault { try { stub.refreshAttributeFinder(finderName); } catch (Exception e) { handleException(e.getMessage(), e); } }
Example #18
Source File: ReportResourceSupplierClient.java From product-es with Apache License 2.0 | 5 votes |
public ReportResourceSupplierClient(String backEndUrl, String sessionCookie) throws RemoteException { this.endPoint = backEndUrl + serviceName; try { reportingResourcesSupplierStub = new ReportingResourcesSupplierStub(endPoint); } catch (AxisFault axisFault) { log.error("Error on initializing reportingResourcesSupplierStub : " + axisFault.getMessage()); throw new RemoteException("Error on initializing reportingResourcesSupplierStub : ", axisFault); } AuthenticateStub.authenticateStub(sessionCookie, reportingResourcesSupplierStub); }
Example #19
Source File: DataServiceAdminClient.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * @param driverClass JDBC driver class name * @param jdbcURL JDBC Url * @param username username * @param password password * @param passwordAlias password alias * @return a string representing success or the failure of the JDBC connection * @throws org.apache.axis2.AxisFault axisFault */ public String testJDBCConnection(String driverClass, String jdbcURL, String username, String password, String passwordAlias) throws AxisFault { String response = ""; try { response = dataServiceAdminStub.testJDBCConnection(driverClass, jdbcURL, username, password, passwordAlias); } catch (RemoteException e) { throw new AxisFault("Error connecting to " + jdbcURL + ". Message from the service is : ", e); } return response; }
Example #20
Source File: DS1169FunctionsWithArrayParametersTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.dss" }, enabled = false) public void testForArrayParameters() throws AxisFault { OMElement payload = fac.createOMElement("getStudentGrades", omNs); OMElement className = fac.createOMElement("class_name", omNs); className.setText("classA"); payload.addChild(className); OMElement studentName1 = fac.createOMElement("student_names", omNs); studentName1.setText("John"); payload.addChild(studentName1); OMElement studentName2 = fac.createOMElement("student_names", omNs); studentName2.setText("Tom"); payload.addChild(studentName2); OMElement result = null; try { result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getStudentGrades"); } catch (XPathExpressionException e) { log.info("FunctionsWithArrayParametersTestCase failed ", e); } Assert.assertNotNull(result, "Response message null "); Assert.assertTrue(result.toString() .contains("<total_score>40</total_score><grades><grade>10</grade>" + "<grade>20</grade></grades>"), "Expected not same"); }
Example #21
Source File: OutSequenceFaultSequenceTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Invalid service referred */ @Test(groups = "wso2.esb", description = "- Custom proxy -Fault sequence inline") public void testCustomProxyFaultInline() { try { axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("StockQuoteProxyFour"), null, "WSO2"); fail("AxisFault Expected"); } catch (AxisFault axisFault) { assertTrue(axisFault.getReason().contains("Fault sequence invoked"), "Fault: value 'reason' mismatched"); } }
Example #22
Source File: EnrichIntegrationReplaceMessageBodyTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.esb", description = "Tests-Replace the body of the target message") public void testReplacingMessageBody() throws AxisFault, XMLStreamException { OMElement response; response = axis2Client .sendCustomQuoteRequest(getProxyServiceURLHttp("enrichReplaceMessageBodyTestProxy"), null, "IBM"); assertNotNull(response, "Response is null"); assertEquals( response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "symbol")) .getText(), "wso2", "Tag does not match"); }
Example #23
Source File: LoadbalanceFailoverClient.java From product-ei with Apache License 2.0 | 5 votes |
public String sessionlessClient() throws AxisFault { OMFactory fac = OMAbstractFactory.getOMFactory(); OMElement value = fac.createOMElement("Value", null); value.setText("Sample string"); Options options = new Options(); options.setTo(new EndpointReference("http://localhost:8480/services/LBService1")); options.setAction("urn:sampleOperation"); long timeout = Integer.parseInt(getProperty("timeout", "10000000")); System.out.println("timeout=" + timeout); options.setTimeOutInMilliSeconds(timeout); // set addressing, transport and proxy url serviceClient.engageModule("addressing"); options.setTo(new EndpointReference("http://localhost:8480")); serviceClient.setOptions(options); String testString = ""; long i = 0; while (i < 100) { serviceClient.getOptions().setManageSession(true); OMElement responseElement = serviceClient.sendReceive(value); String response = responseElement.getText(); i++; System.out.println("Request: " + i + " ==> " + response); testString = testString.concat(":" + i + ">" + response + ":"); } return testString; }
Example #24
Source File: HostObjectComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Activate protected void activate(ComponentContext componentContext) { try { ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(getClientRepoLocation(), getAxis2ClientXmlLocation()); ServiceReferenceHolder.getInstance().setAxis2ConfigurationContext(ctx); if (log.isDebugEnabled()) { log.debug("HostObjectComponent activated"); } } catch (AxisFault axisFault) { log.error("Error while initializing the API HostObject component", axisFault); } }
Example #25
Source File: IdentityManagementAdminClient.java From carbon-identity with Apache License 2.0 | 5 votes |
public ChallengeQuestionDTO[] getChallengeQuestions() throws AxisFault { try { return stub.getAllChallengeQuestions(); } catch (Exception e) { handleException(e.getMessage(), e); } return new ChallengeQuestionDTO[0]; }
Example #26
Source File: StockQuoteClient.java From product-ei with Apache License 2.0 | 5 votes |
/** * Send place order request * * @param trpUrl transport url * @param addUrl address url * @param symbol symbol * @throws AxisFault if error occurs when sending request */ public void sendPlaceOrderRequest(String trpUrl, String addUrl, String symbol) throws AxisFault { double price = getRandom(100, 0.9, true); int quantity = (int) getRandom(10000, 1.0, true); ServiceClient serviceClient = getServiceClient(trpUrl, addUrl, "placeOrder"); try { serviceClient.fireAndForget(createPlaceOrderRequest(price, quantity, symbol)); } finally { serviceClient.cleanupTransport(); } }
Example #27
Source File: EntitlementServiceClient.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * Evaluate XACML request with PDP * * @param request XACML request as String * @return XACML response as String * @throws AxisFault if fails */ public String getDecision(String request) throws AxisFault { try { return stub.getDecision(request); } catch (Exception e) { handleException("Error occurred while policy evaluation", e); } return null; }
Example #28
Source File: ValidateIntegrationNegativeTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"}, description = "Create validate mediator and specifying an invalid " + "XPath expression using \"source\" attribute " + "Check how mediator operates on the elements of SOAP body") public void TestWithInvalidXpath() throws Exception { final String expectedErrorMsg = "Error occurred while accessing source element: //m0:requestElement/m0:getQuote"; try { axis2Client.sendSimpleStockQuoteRequest( getProxyServiceURLHttp("validateMediatorInvalidXPathTestProxy"), null, "WSO2"); } catch (AxisFault expected) { assertEquals(expected.getMessage(), expectedErrorMsg, "Error Message mismatched"); } }
Example #29
Source File: SendMessageWithoutSecurityHeadersTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.esb", description = "- Secure proxy" + "- Send a message without security headers to a secure proxy", expectedExceptions = {AxisFault.class}) public void testSendingMessagesWithoutSecHeaders() throws Exception { applySecurity(); axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("StockQuoteProxy"), null, "WSO2"); fail("Fault: Should be an AxisFault"); // TODO - Assert the synapse log for " org.apache.axis2.AxisFault: SOAP header missing" }
Example #30
Source File: InvalidTargetAddressTestCase.java From product-ei with Apache License 2.0 | 5 votes |
/** * This sets an invalid "To Address" in the clone target and message is mediated and see whether the service * can be found for the end point reference. */ @Test(groups = {"wso2.esb"}, description = "Tests an invalid 'To Address'' in the clone target") public void testInvalidTargetAddress() throws Exception{ try { axis2Client.sendMultipleQuoteRequest( getProxyServiceURLHttp("iterateInvalidTargetAddressTestProxy"), null, symbol, 4); Assert.fail("This Request must throw AxisFault"); // This will execute when the exception is not thrown as expected } catch (AxisFault message) { assertEquals(message.getReason(), ESBTestConstant.READ_TIME_OUT, "Iterator mediator worked even with an invalid clone target address."); } }