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);
}
}
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;
}
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
}
}
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);
}
}
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);
}
}
Aggregations