use of com.netsuite.webservices.v2016_2.platform.NetSuiteService 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 com.netsuite.webservices.v2016_2.platform.NetSuiteService 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/2016.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 | InsufficientPermissionFault | InvalidCredentialsFault | InvalidSessionFault | UnexpectedErrorFault | ExceededRequestSizeFault e) {
throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.failedToInitClient", e.getLocalizedMessage()), e);
}
}
Aggregations