Search in sources :

Example 11 with WebServiceException

use of javax.xml.ws.WebServiceException in project components by Talend.

the class NetSuiteClientServiceImpl method getNetSuitePort.

protected NetSuitePortType getNetSuitePort(String defaultEndpointUrl, String account) throws NetSuiteException {
    try {
        URL wsdlLocationUrl = this.getClass().getResource("/wsdl/2014.2/netsuite.wsdl");
        NetSuiteService service = new NetSuiteService(wsdlLocationUrl, NetSuiteService.SERVICE);
        List<WebServiceFeature> features = new ArrayList<>(2);
        if (isMessageLoggingEnabled()) {
            features.add(new LoggingFeature());
        }
        NetSuitePortType port = service.getNetSuitePort(features.toArray(new WebServiceFeature[features.size()]));
        BindingProvider provider = (BindingProvider) port;
        Map<String, Object> requestContext = provider.getRequestContext();
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, defaultEndpointUrl);
        GetDataCenterUrlsRequest dataCenterRequest = new GetDataCenterUrlsRequest();
        dataCenterRequest.setAccount(account);
        DataCenterUrls urls = null;
        GetDataCenterUrlsResponse response = port.getDataCenterUrls(dataCenterRequest);
        if (response != null && response.getGetDataCenterUrlsResult() != null) {
            urls = response.getGetDataCenterUrlsResult().getDataCenterUrls();
        }
        if (urls == null) {
            throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.couldNotGetWebServiceDomain", defaultEndpointUrl));
        }
        String wsDomain = urls.getWebservicesDomain();
        String endpointUrl = wsDomain.concat(new URL(defaultEndpointUrl).getPath());
        requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
        return port;
    } catch (WebServiceException | MalformedURLException | UnexpectedErrorFault | ExceededRequestSizeFault e) {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.failedToInitClient", e.getLocalizedMessage()), e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) GetDataCenterUrlsResponse(com.netsuite.webservices.v2014_2.platform.messages.GetDataCenterUrlsResponse) ArrayList(java.util.ArrayList) DataCenterUrls(com.netsuite.webservices.v2014_2.platform.core.DataCenterUrls) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) UnexpectedErrorFault(com.netsuite.webservices.v2014_2.platform.UnexpectedErrorFault) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) NetSuitePortType(com.netsuite.webservices.v2014_2.platform.NetSuitePortType) NetSuiteErrorCode(org.talend.components.netsuite.NetSuiteErrorCode) NetSuiteService(com.netsuite.webservices.v2014_2.platform.NetSuiteService) LoggingFeature(org.apache.cxf.feature.LoggingFeature) WebServiceFeature(javax.xml.ws.WebServiceFeature) GetDataCenterUrlsRequest(com.netsuite.webservices.v2014_2.platform.messages.GetDataCenterUrlsRequest) ExceededRequestSizeFault(com.netsuite.webservices.v2014_2.platform.ExceededRequestSizeFault)

Example 12 with WebServiceException

use of javax.xml.ws.WebServiceException in project components by Talend.

the class MarketoSOAPClient method connect.

public MarketoSOAPClient connect() throws MarketoException {
    try {
        port = getMktowsApiSoapPort();
        LOG.debug("Marketo SOAP Client :: port.");
        header = getAuthentificationHeader();
        LOG.debug("Marketo SOAP Client initialization :: AuthHeader.");
        // bug/TDI-38439_MarketoWizardConnection : make a dummy call to check auth and not just URL.
        getPort().listMObjects(new ParamsListMObjects(), header);
    } catch (MalformedURLException | NoSuchAlgorithmException | InvalidKeyException | WebServiceException e) {
        throw new MarketoException(SOAP, e.getMessage());
    }
    return this;
}
Also used : MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) MarketoException(org.talend.components.marketo.runtime.client.type.MarketoException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ParamsListMObjects(com.marketo.mktows.ParamsListMObjects) InvalidKeyException(java.security.InvalidKeyException)

Example 13 with WebServiceException

use of javax.xml.ws.WebServiceException in project syncope by apache.

the class JWTITCase method queryUsingToken.

@Test
public void queryUsingToken() throws ParseException {
    // Get the token
    SyncopeClient localClient = clientFactory.create(ADMIN_UNAME, ADMIN_PWD);
    AccessTokenService accessTokenService = localClient.getService(AccessTokenService.class);
    Response response = accessTokenService.login();
    String token = response.getHeaderString(RESTHeaders.TOKEN);
    assertNotNull(token);
    // Query the UserSelfService using the token
    SyncopeClient jwtClient = clientFactory.create(token);
    UserSelfService jwtUserSelfService = jwtClient.getService(UserSelfService.class);
    jwtUserSelfService.read();
    // Test a "bad" token
    jwtClient = clientFactory.create(token + "xyz");
    jwtUserSelfService = jwtClient.getService(UserSelfService.class);
    try {
        jwtUserSelfService.read();
        fail("Failure expected on a modified token");
    } catch (WebServiceException ex) {
    // expected
    }
}
Also used : Response(javax.ws.rs.core.Response) WebServiceException(javax.xml.ws.WebServiceException) AccessTokenService(org.apache.syncope.common.rest.api.service.AccessTokenService) UserSelfService(org.apache.syncope.common.rest.api.service.UserSelfService) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) Test(org.junit.jupiter.api.Test)

Example 14 with WebServiceException

use of javax.xml.ws.WebServiceException in project syncope by apache.

the class LoggerCreate method create.

public void create() {
    if (input.parameterNumber() >= 1) {
        final List<LoggerTO> loggerTOs = new ArrayList<>();
        boolean failed = false;
        for (String parameter : input.getParameters()) {
            LoggerTO loggerTO = new LoggerTO();
            Pair<String, String> pairParameter = Input.toPairParameter(parameter);
            try {
                loggerTO.setKey(pairParameter.getKey());
                loggerTO.setLevel(LoggerLevel.valueOf(pairParameter.getValue()));
                loggerSyncopeOperations.update(loggerTO);
                loggerTOs.add(loggerTO);
            } catch (WebServiceException | SyncopeClientException | IllegalArgumentException ex) {
                LOG.error("Error creating logger", ex);
                loggerResultManager.typeNotValidError("logger level", input.firstParameter(), CommandUtils.fromEnumToArray(LoggerLevel.class));
                failed = true;
                break;
            }
        }
        if (!failed) {
            loggerResultManager.fromUpdate(loggerTOs);
        }
    } else {
        loggerResultManager.commandOptionError(CREATE_HELP_MESSAGE);
    }
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException)

Example 15 with WebServiceException

use of javax.xml.ws.WebServiceException in project teiid by teiid.

the class BinaryWSProcedureExecution method execute.

public void execute() throws TranslatorException {
    List<Argument> arguments = this.procedure.getArguments();
    String method = (String) arguments.get(0).getArgumentValue().getValue();
    Object payload = arguments.get(1).getArgumentValue().getValue();
    String endpoint = (String) arguments.get(2).getArgumentValue().getValue();
    try {
        Dispatch<DataSource> dispatch = this.conn.createDispatch(HTTPBinding.HTTP_BINDING, endpoint, DataSource.class, Mode.MESSAGE);
        if (method == null) {
            // $NON-NLS-1$
            method = "POST";
        }
        dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, method);
        if (payload != null && !"POST".equalsIgnoreCase(method) && !"PUT".equalsIgnoreCase(method) && !"PATCH".equalsIgnoreCase(method)) {
            // $NON-NLS-1$
            throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error"));
        }
        Map<String, List<String>> httpHeaders = (Map<String, List<String>>) dispatch.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
        if (customHeaders != null) {
            httpHeaders.putAll(customHeaders);
        }
        if (arguments.size() > 5 && // designer modeled the return value as an out, which will add an argument in the 5th position that is an out
        this.procedure.getMetadataObject() != null && (this.procedure.getMetadataObject().getParameters().get(0).getType() == Type.ReturnValue || arguments.get(5).getMetadataObject().getSourceName().equalsIgnoreCase("headers"))) {
            // $NON-NLS-1$
            Clob headers = (Clob) arguments.get(5).getArgumentValue().getValue();
            if (headers != null) {
                parseHeader(httpHeaders, headers);
            }
        }
        dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
        DataSource ds = null;
        if (payload instanceof String) {
            ds = new InputStreamFactory.ClobInputStreamFactory(new ClobImpl((String) payload));
        } else if (payload instanceof SQLXML) {
            ds = new InputStreamFactory.SQLXMLInputStreamFactory((SQLXML) payload);
        } else if (payload instanceof Clob) {
            ds = new InputStreamFactory.ClobInputStreamFactory((Clob) payload);
        } else if (payload instanceof Blob) {
            ds = new InputStreamFactory.BlobInputStreamFactory((Blob) payload);
        }
        this.returnValue = dispatch.invoke(ds);
        Map<String, Object> rc = dispatch.getResponseContext();
        this.responseCode = (Integer) rc.get(WSConnection.STATUS_CODE);
        if (this.useResponseContext) {
            // it's presumed that the caller will handle the response codes
            this.responseContext = rc;
        } else {
            // TODO: may need to add logic around some 200/300 codes - cxf should at least be logging this
            if (this.responseCode >= 400) {
                String message = conn.getStatusMessage(this.responseCode);
                throw new TranslatorException(WSExecutionFactory.Event.TEIID15005, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15005, this.responseCode, message));
            }
        }
    } catch (WebServiceException e) {
        throw new TranslatorException(e);
    } catch (ParseException e) {
        throw new TranslatorException(e);
    } catch (IOException e) {
        throw new TranslatorException(e);
    } catch (SQLException e) {
        throw new TranslatorException(e);
    }
}
Also used : Blob(java.sql.Blob) Argument(org.teiid.language.Argument) WebServiceException(javax.xml.ws.WebServiceException) SQLException(java.sql.SQLException) IOException(java.io.IOException) InputStreamFactory(org.teiid.core.types.InputStreamFactory) DataSource(javax.activation.DataSource) SQLXML(java.sql.SQLXML) List(java.util.List) TranslatorException(org.teiid.translator.TranslatorException) ParseException(org.json.simple.parser.ParseException) Clob(java.sql.Clob) HashMap(java.util.HashMap) Map(java.util.Map) ClobImpl(org.teiid.core.types.ClobImpl)

Aggregations

WebServiceException (javax.xml.ws.WebServiceException)378 Test (org.junit.Test)115 SOAPException (javax.xml.soap.SOAPException)59 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)59 SOAPMessage (javax.xml.soap.SOAPMessage)57 ConnectException (java.net.ConnectException)48 ErrorCode (org.olat.modules.vitero.model.ErrorCode)48 URL (java.net.URL)46 SOAPElement (javax.xml.soap.SOAPElement)46 IOException (java.io.IOException)43 SOAPBody (javax.xml.soap.SOAPBody)34 ArrayList (java.util.ArrayList)32 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)32 BindingProvider (javax.xml.ws.BindingProvider)31 Retry (io.github.resilience4j.retry.Retry)29 Service (javax.xml.ws.Service)29 QName (javax.xml.namespace.QName)27 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)21 DataHandler (javax.activation.DataHandler)17 RetryConfig (io.github.resilience4j.retry.RetryConfig)16