use of com.netsuite.webservices.platform.NetSuiteService in project tdi-studio-se by Talend.
the class NetsuiteManagement_CXF method initializeStub.
public void initializeStub() throws Exception {
URL wsdl_locationUrl = this.getClass().getResource("/wsdl/netsuite.wsdl");
QName serviceQname = new QName("urn:platform_2014_2.webservices.netsuite.com", "NetSuiteService");
NetSuiteService service = new NetSuiteService(wsdl_locationUrl, serviceQname);
NetSuitePortType port = service.getNetSuitePort();
BindingProvider provider = (BindingProvider) port;
Map<String, Object> requestContext = provider.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, _url);
Preferences preferences = new Preferences();
preferences.setDisableMandatoryCustomFieldValidation(Boolean.FALSE);
preferences.setWarningAsError(Boolean.FALSE);
preferences.setIgnoreReadOnlyFields(Boolean.TRUE);
preferences.setDisableMandatoryCustomFieldValidation(Boolean.TRUE);
SearchPreferences searchPreferences = new SearchPreferences();
searchPreferences.setPageSize(this._pageSize);
searchPreferences.setBodyFieldsOnly(Boolean.valueOf(false));
RecordRef role = new RecordRef();
role.setInternalId(this._role);
Passport passport = new Passport();
passport.setEmail(this._email);
passport.setPassword(this._pwd);
passport.setRole(role);
passport.setAccount(this._account);
// Get the webservices domain for your account
GetDataCenterUrlsRequest dataCenterRequest = new GetDataCenterUrlsRequest();
dataCenterRequest.setAccount(this._account);
DataCenterUrls urls = null;
GetDataCenterUrlsResponse reponse = port.getDataCenterUrls(dataCenterRequest);
if (reponse != null && reponse.getGetDataCenterUrlsResult() != null) {
urls = reponse.getGetDataCenterUrlsResult().getDataCenterUrls();
}
if (urls == null) {
throw new Exception("Can't get a correct webservice domain! Please check your configuration or try to run again.");
}
String wsDomain = urls.getWebservicesDomain();
String endpoint = wsDomain.concat(new URL(this._url).getPath());
requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
List<Header> list = (List<Header>) requestContext.get(Header.HEADER_LIST);
if (list == null) {
list = new ArrayList<Header>();
requestContext.put(Header.HEADER_LIST, list);
}
Header searchPreferences_header = new Header(new QName("urn:messages_2014_2.platform.webservices.netsuite.com", "searchPreferences"), searchPreferences, new JAXBDataBinding(searchPreferences.getClass()));
Header preferences_header = new Header(new QName("urn:messages_2014_2.platform.webservices.netsuite.com", "preferences"), preferences, new JAXBDataBinding(preferences.getClass()));
list.add(searchPreferences_header);
list.add(preferences_header);
LoginRequest request = new LoginRequest();
request.setPassport(passport);
port.login(request);
this._port = port;
Arrays.asList(new String[] { "", "", "" });
}
Aggregations