Search in sources :

Example 1 with GetDataCenterUrlsRequest

use of com.netsuite.webservices.platform.messages.GetDataCenterUrlsRequest 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[] { "", "", "" });
}
Also used : GetDataCenterUrlsResponse(com.netsuite.webservices.platform.messages.GetDataCenterUrlsResponse) QName(javax.xml.namespace.QName) RecordRef(com.netsuite.webservices.platform.core.RecordRef) ListOrRecordRef(com.netsuite.webservices.platform.core.ListOrRecordRef) DataCenterUrls(com.netsuite.webservices.platform.core.DataCenterUrls) BindingProvider(javax.xml.ws.BindingProvider) LoginRequest(com.netsuite.webservices.platform.messages.LoginRequest) URL(java.net.URL) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) SOAPException(javax.xml.soap.SOAPException) ParseException(java.text.ParseException) JAXBException(javax.xml.bind.JAXBException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedURLException(java.net.MalformedURLException) NetSuitePortType(com.netsuite.webservices.platform.NetSuitePortType) SearchPreferences(com.netsuite.webservices.platform.messages.SearchPreferences) Passport(com.netsuite.webservices.platform.core.Passport) Header(org.apache.cxf.headers.Header) NetSuiteService(com.netsuite.webservices.platform.NetSuiteService) GetDataCenterUrlsRequest(com.netsuite.webservices.platform.messages.GetDataCenterUrlsRequest) List(java.util.List) SearchCustomFieldList(com.netsuite.webservices.platform.core.SearchCustomFieldList) ArrayList(java.util.ArrayList) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) SearchPreferences(com.netsuite.webservices.platform.messages.SearchPreferences) Preferences(com.netsuite.webservices.platform.messages.Preferences)

Aggregations

NetSuitePortType (com.netsuite.webservices.platform.NetSuitePortType)1 NetSuiteService (com.netsuite.webservices.platform.NetSuiteService)1 DataCenterUrls (com.netsuite.webservices.platform.core.DataCenterUrls)1 ListOrRecordRef (com.netsuite.webservices.platform.core.ListOrRecordRef)1 Passport (com.netsuite.webservices.platform.core.Passport)1 RecordRef (com.netsuite.webservices.platform.core.RecordRef)1 SearchCustomFieldList (com.netsuite.webservices.platform.core.SearchCustomFieldList)1 GetDataCenterUrlsRequest (com.netsuite.webservices.platform.messages.GetDataCenterUrlsRequest)1 GetDataCenterUrlsResponse (com.netsuite.webservices.platform.messages.GetDataCenterUrlsResponse)1 LoginRequest (com.netsuite.webservices.platform.messages.LoginRequest)1 Preferences (com.netsuite.webservices.platform.messages.Preferences)1 SearchPreferences (com.netsuite.webservices.platform.messages.SearchPreferences)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JAXBException (javax.xml.bind.JAXBException)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1