Java Code Examples for org.apache.axis2.AxisFault#getMessage()

The following examples show how to use org.apache.axis2.AxisFault#getMessage() . 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: ESBJAVA2824MissingResponseTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "Test Sending message to a jms endpoint and check for response")
public void testJmsResponse() throws Exception {
	try {
		axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(),
				null, "IBM");
		
	} catch (AxisFault fault) {
		String errMsg=fault.getMessage();						
		Assert.assertEquals(errMsg,"Send timeout", "JMS Client did not receive Send timeout");			
		
		LogViewerClient cli = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
		LogEvent[] logs = cli.getAllRemoteSystemLogs();
		Assert.assertNotNull(logs, "No logs found");
		Assert.assertTrue(logs.length > 0, "No logs found");
		boolean errorMsgTrue = Utils.checkForLogsWithPriority(cli,"ERROR", logLine0, 10);
		Assert.assertTrue(errorMsgTrue, "Axis Fault Did not receive");
	}
}
 
Example 2
Source File: EmailVerificationServiceClient.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public EmailVerificationServiceClient(
        String cookie, String backendServerURL, ConfigurationContext configContext)
        throws RegistryException {

    epr = backendServerURL + "EmailVerificationService";

    try {
        stub = new EmailVerificationServiceStub(configContext, epr);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

    } catch (AxisFault axisFault) {
        String msg = "Failed to initiate AddServices service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}
 
Example 3
Source File: SubscriptionUpdateWSWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {
    String errorMsg = null;
    super.cleanUpPendingTask(workflowExtRef);
    try {
        String action = WorkflowConstants.DELETE_SUBSCRIPTION_WS_ACTION;
        ServiceClient client = getClient(action);
        String payload = "<wor:CancelSubscriptionApprovalWorkflowProcessRequest " +
                "           xmlns:wor=\"http://workflow.subscription.apimgt.carbon.wso2.org\">\n" +
                "           <wor:workflowExtRef>" + workflowExtRef + "</wor:workflowExtRef>\n" +
                "        </wor:CancelSubscriptionApprovalWorkflowProcessRequest>";

        client.fireAndForget(AXIOMUtil.stringToOM(payload));
    } catch (AxisFault axisFault) {
        errorMsg = "Error sending out cancel pending subscription approval process message. cause: " + axisFault
                .getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    } catch (XMLStreamException e) {
        errorMsg = "Error converting subscription cleanup String to OMElement. cause: " + e.getMessage();
        throw new WorkflowException(errorMsg, e);
    }
}
 
Example 4
Source File: XSLTTransformationCarTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.esb"}, description = "test endpoint deployment from car file")
public void artifactDeploymentAndServiceInvocation() throws Exception {
    Assert.assertTrue(esbUtils.isEndpointDeployed(context.getContextUrls().getBackEndUrl(), getSessionCookie(), "stockQuoteServiceEndpoint")
            , "AddressEndpoint Endpoint deployment failed");
    Assert.assertTrue(esbUtils.isProxyDeployed(context.getContextUrls().getBackEndUrl(), getSessionCookie(), "xsltTransformationProxy")
            , "Pass Through Proxy service deployment failed");
    Assert.assertTrue(isResourceExist("/_system/config/transform.xslt"), "transform.xslt not found on registry");
    Assert.assertTrue(isResourceExist("/_system/config/transform_back.xslt"), "transform.xslt not found on registry");

    OMElement response = null;
    try {
        response = axis2Client.sendCustomQuoteRequest(
                getProxyServiceURLHttp("xsltTransformationProxy"),
                null,
                "XSLTTransformation");
    } catch (AxisFault axisFault) {
        throw new Exception("Service Invocation Failed > " + axisFault.getMessage(), axisFault);
    }
    Assert.assertNotNull(response, "Response message null");
    Assert.assertTrue(response.toString().contains("Code"), "Code element not found in response message");
    Assert.assertTrue(response.toString().contains("XSLTTransformation"), "Symbol not found on the response message");

}
 
Example 5
Source File: IdentityApplicationManagementServiceClient.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
public IdentityApplicationManagementServiceClient(String epr) throws AxisFault {

        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int autosclaerSocketTimeout = conf.getInt("autoscaler.identity.clientTimeout", 180000);
        try {
            ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
            String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
            String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
            String type = serverConfig.getFirstProperty("Security.TrustStore.Type");

            System.setProperty("javax.net.ssl.trustStore", trustStorePath);
            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
            System.setProperty("javax.net.ssl.trustStoreType", type);

            stub = new IdentityApplicationManagementServiceStub(epr);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, autosclaerSocketTimeout);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, autosclaerSocketTimeout);
	        String username = conf.getString("autoscaler.identity.adminUser", "admin");
            Utility.setAuthHeaders(stub._getServiceClient(), username);

        } catch (AxisFault axisFault) {
            String msg = "Failed to initiate identity service client. " + axisFault.getMessage();
            log.error(msg, axisFault);
            throw new AxisFault(msg, axisFault);
        }
    }
 
Example 6
Source File: InfoServiceAdminClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public InfoServiceAdminClient(String backEndUrl, String sessionCookie)
        throws RegistryException, AxisFault {
    String serviceName = "InfoAdminService";
    String endPoint = backEndUrl + serviceName;
    try {
        infoAdminServiceStub = new InfoAdminServiceStub(endPoint);
        AuthenticateStub.authenticateStub(sessionCookie, infoAdminServiceStub);
    } catch (AxisFault axisFault) {
        log.error("infoAdminServiceStub Initialization fail " + axisFault.getMessage());
        throw new AxisFault("infoAdminServiceStub Initialization fail " + axisFault.getMessage());
    }

}
 
Example 7
Source File: StratosApiV41Utils.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
/**
 * Get CloudController Service Client
 *
 * @return CloudControllerServiceClient
 * @throws RestAPIException
 */
private static CloudControllerServiceClient getCloudControllerServiceClient() throws RestAPIException {

    try {
        return CloudControllerServiceClient.getInstance();

    } catch (AxisFault axisFault) {
        String errorMsg = "Error while getting CloudControllerServiceClient instance to connect to the "
                + "Cloud Controller. Cause: " + axisFault.getMessage();
        log.error(errorMsg, axisFault);
        throw new RestAPIException(errorMsg, axisFault);
    }
}
 
Example 8
Source File: BasicAuthCredentialValidator.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the validator with the synapse environment.
 *
 * @throws APISecurityException If an authentication failure or some other error occurs
 */
BasicAuthCredentialValidator() throws APISecurityException {
    this.gatewayKeyCacheEnabled = isGatewayTokenCacheEnabled();
    this.getGatewayUsernameCache();

    ConfigurationContext configurationContext = ServiceReferenceHolder.getInstance().getAxis2ConfigurationContext();
    APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration();
    String username = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_USERNAME);
    String password = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_PASSWORD);
    String url = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_URL);
    if (url == null) {
        throw new APISecurityException(APISecurityConstants.API_AUTH_GENERAL_ERROR,
                "API key manager URL unspecified");
    }

    try {
        apiKeyMgtRemoteUserStoreMgtServiceStub = new APIKeyMgtRemoteUserStoreMgtServiceStub(configurationContext, url +
                "APIKeyMgtRemoteUserStoreMgtService");
        ServiceClient client = apiKeyMgtRemoteUserStoreMgtServiceStub._getServiceClient();
        Options options = client.getOptions();
        options.setCallTransportCleanup(true);
        options.setManageSession(true);
        CarbonUtils.setBasicAccessSecurityHeaders(username, password, client);
    } catch (AxisFault axisFault) {
        throw new APISecurityException(APISecurityConstants.API_AUTH_GENERAL_ERROR, axisFault.getMessage(), axisFault);
    }
}
 
Example 9
Source File: AxisServiceClientUtils.java    From product-ei with Apache License 2.0 5 votes vote down vote up
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 10
Source File: AxisServiceClientUtils.java    From product-ei with Apache License 2.0 5 votes vote down vote up
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 11
Source File: RepositoryInformationServiceClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param epr end point reference for the RepositoryInformationServiceClient
 *
 * @throws AxisFault
 */
public RepositoryInformationServiceClient (String epr) throws AxisFault {

    try {
        repositoryInformationServiceStub = new RepositoryInformationServiceStub(epr);

    } catch (AxisFault axisFault) {
        String errorMsg = "Repository Information Service client initialization failed " + axisFault.getMessage();
        log.error(errorMsg, axisFault);
        throw new AxisFault(errorMsg, axisFault);
    }
}
 
Example 12
Source File: StratosApiV41Utils.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
/**
 * Get Stratos Manager Service Client
 *
 * @return StratosManagerServiceClient
 * @throws RestAPIException
 */
private static StratosManagerServiceClient getStratosManagerServiceClient() throws RestAPIException {
    try {
        return StratosManagerServiceClient.getInstance();
    } catch (AxisFault axisFault) {
        String errorMsg = "Error while getting StratosManagerServiceClient instance to connect to the "
                + "Stratos Manager. Cause: " + axisFault.getMessage();
        log.error(errorMsg, axisFault);
        throw new RestAPIException(errorMsg, axisFault);
    }
}
 
Example 13
Source File: AARServiceUploaderClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public AARServiceUploaderClient(String backEndUrl, String sessionCookie) throws AxisFault {

        String endPoint = backEndUrl + serviceName;
        try {
            serviceUploaderStub = new ServiceUploaderStub(endPoint);
            AuthenticateStub.authenticateStub(sessionCookie, serviceUploaderStub);
        } catch (AxisFault axisFault) {
            log.error("ServiceUploaderStub Initialization fail " + axisFault.getMessage());
            throw new AxisFault("ServiceUploaderStub Initialization fail " + axisFault.getMessage());
        }
    }
 
Example 14
Source File: OAuthMediator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void init(SynapseEnvironment synEnv) {
    try {
        cfgCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientRepository != null
                ? clientRepository : DEFAULT_CLIENT_REPO, axis2xml != null ? axis2xml : DEFAULT_AXIS2_XML);
    } catch (AxisFault e) {
        String msg = "Error initializing OAuth mediator : " + e.getMessage();
        throw new SynapseException(msg, e);
    }
}
 
Example 15
Source File: InfoServiceAdminClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public InfoServiceAdminClient(String backEndUrl, String userName, String password)
        throws RegistryException, AxisFault {
    String serviceName = "InfoAdminService";
    String endPoint = backEndUrl + serviceName;
    try {
        infoAdminServiceStub = new InfoAdminServiceStub(endPoint);
        AuthenticateStub.authenticateStub(userName, password, infoAdminServiceStub);
    } catch (AxisFault axisFault) {
        log.error("infoAdminServiceStub Initialization fail " + axisFault.getMessage());
        throw new AxisFault("infoAdminServiceStub Initialization fail " + axisFault.getMessage());
    }

}
 
Example 16
Source File: AxisServiceClientUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
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 17
Source File: AxisServiceClientUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
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 18
Source File: InfoServiceAdminClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public InfoServiceAdminClient(String backEndUrl, String userName, String password)
        throws RegistryException, AxisFault {
    String serviceName = "InfoAdminService";
    String endPoint = backEndUrl + serviceName;
    try {
        infoAdminServiceStub = new InfoAdminServiceStub(endPoint);
        AuthenticateStub.authenticateStub(userName, password, infoAdminServiceStub);
    } catch (AxisFault axisFault) {
        log.error("infoAdminServiceStub Initialization fail " + axisFault.getMessage());
        throw new AxisFault("infoAdminServiceStub Initialization fail " + axisFault.getMessage());
    }

}
 
Example 19
Source File: StratosApiV40Utils.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private static CloudControllerServiceClient getCloudControllerServiceClient() throws RestAPIException {

        try {
            return CloudControllerServiceClient.getInstance();

        } catch (AxisFault axisFault) {
            String errorMsg = "Error while getting CloudControllerServiceClient instance to connect to the "
                    + "Cloud Controller. Cause: " + axisFault.getMessage();
            log.error(errorMsg, axisFault);
            throw new RestAPIException(errorMsg, axisFault);
        }
    }
 
Example 20
Source File: OAuthAdminServiceClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public OAuthAdminServiceClient(String epr) throws AxisFault {

        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int autosclaerSocketTimeout = conf.getInt("autoscaler.identity.clientTimeout", 180000);

        try {
            ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
            String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
            String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
            String type = serverConfig.getFirstProperty("Security.TrustStore.Type");
            System.setProperty("javax.net.ssl.trustStore", trustStorePath);
            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
            System.setProperty("javax.net.ssl.trustStoreType", type);

            stub = new OAuthAdminServiceStub(epr);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, autosclaerSocketTimeout);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, autosclaerSocketTimeout);
            //String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
            //TODO StratosAuthenticationHandler does not set to carbon context, thus user name becomes null.
            // For the moment username is hardcoded since above is fixed.
            String username = conf.getString("autoscaler.identity.adminUser", "admin");
            Utility.setAuthHeaders(stub._getServiceClient(), username);

        } catch (AxisFault axisFault) {
            String msg = "Failed to initiate identity service client. " + axisFault.getMessage();
            log.error(msg, axisFault);
            throw new AxisFault(msg, axisFault);
        }
    }