NetSuite是否支持Apache Axis 2.0?

时间:2019-06-24 13:41:07

标签: java apache netsuite axis axis2

我正在尝试通过使用SOAP WebServices连接NetSuite系统。我已使用apache轴1.7.9从WSDL 2019生成Java存根。

我曾尝试使用搜索方法获取员工记录,但低于异常。

Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException: Unsupported type urn:core_2019_1.platform.webservices.netsuite.com BooleanCustomFieldRef

因此引起人们注意的是Apache Axis2的原因。 NetSuite仍然不支持Apache Axis 2吗?

package com.org;


import java.rmi.RemoteException;

import org.apache.axis2.AxisFault;

import com.netsuite.webservices.lists.employees_2019_1.EmployeeSearch;
import com.netsuite.webservices.platform.common_2019_1.EmployeeSearchBasic;
import com.netsuite.webservices.platform.core_2019_1.Passport;
import com.netsuite.webservices.platform.core_2019_1.RecordRef;
import com.netsuite.webservices.platform.core_2019_1.SearchStringField;
import com.netsuite.webservices.platform.core_2019_1.TokenPassport;
import com.netsuite.webservices.platform.core_2019_1.TokenPassportSignature;
import com.netsuite.webservices.platform.core_2019_1.types.RecordType;
import com.netsuite.webservices.platform.core_2019_1.types.SearchStringFieldOperator;
import com.netsuite.webservices.platform.messages_2019_1.ApplicationInfo;
import com.netsuite.webservices.platform.messages_2019_1.ApplicationInfoE;
import com.netsuite.webservices.platform.messages_2019_1.Login;
import com.netsuite.webservices.platform.messages_2019_1.LoginRequest;
import com.netsuite.webservices.platform.messages_2019_1.LoginResponseE;
import com.netsuite.webservices.platform.messages_2019_1.PartnerInfo;
import com.netsuite.webservices.platform.messages_2019_1.PartnerInfoE;
import com.netsuite.webservices.platform.messages_2019_1.Search;
import com.netsuite.webservices.platform.messages_2019_1.SearchPreferences;
import com.netsuite.webservices.platform.messages_2019_1.SearchPreferencesE;
import com.netsuite.webservices.platform.messages_2019_1.SearchRequest;
import com.netsuite.webservices.platform.messages_2019_1.SearchResponseE;
import com.netsuite.webservices.platform_2019_1.ExceededConcurrentRequestLimitFault;
import com.netsuite.webservices.platform_2019_1.ExceededRecordCountFault;
import com.netsuite.webservices.platform_2019_1.ExceededRequestLimitFault;
import com.netsuite.webservices.platform_2019_1.ExceededRequestSizeFault;
import com.netsuite.webservices.platform_2019_1.ExceededUsageLimitFault;
import com.netsuite.webservices.platform_2019_1.InsufficientPermissionFault;
import com.netsuite.webservices.platform_2019_1.InvalidAccountFault;
import com.netsuite.webservices.platform_2019_1.InvalidCredentialsFault;
import com.netsuite.webservices.platform_2019_1.InvalidSessionFault;
import com.netsuite.webservices.platform_2019_1.InvalidVersionFault;
import com.netsuite.webservices.platform_2019_1.NetSuiteService;
import com.netsuite.webservices.platform_2019_1.NetSuiteServiceStub;
import com.netsuite.webservices.platform_2019_1.UnexpectedErrorFault;

public class Client {



    public static void main(String[] args) {

         Passport passport = new Passport();
         passport.setAccount("ASDfsdfsadf");
         passport.setEmail("sdfsdfdsf");
         passport.setPassword("asdfsdf");

         com.netsuite.webservices.platform.messages_2019_1.Passport passport1 = new com.netsuite.webservices.platform.messages_2019_1.Passport();
         passport1.setPassport(passport);

         ApplicationInfo appInfo = new ApplicationInfo();
         appInfo.setApplicationId("sdfdsfdsfsdf");
         ApplicationInfoE  ai = new ApplicationInfoE();
         ai.setApplicationInfo(appInfo);

         LoginRequest lr = new LoginRequest();
         lr.setPassport(passport);

         Login login = new Login();

         login.setLogin(lr);

         Search search = new Search();
         SearchRequest searchRequest= new SearchRequest();
         searchRequest.setSearchRecord(createEmployeeSearch());
         search.setSearch(searchRequest);

         com.netsuite.webservices.platform.messages_2019_1.TokenPassport token = new com.netsuite.webservices.platform.messages_2019_1.TokenPassport();
         TokenPassport tp = new TokenPassport();
         tp.setAccount("sdfsdfsdf");
         tp.setConsumerKey("dfdsfsdfsdfsdf");
         tp.setToken("Token Based Integration");
         tp.setNonce("nonce");

         TokenPassportSignature tps = new TokenPassportSignature();
         tps.setString("Suraj");
         tps.setAlgorithm("Algo");
         tp.setSignature(tps);
         token.setTokenPassport(tp);

         PartnerInfoE pre = new PartnerInfoE();
         pre.setPartnerInfo(new PartnerInfo());

         SearchPreferencesE spe = new SearchPreferencesE();
         spe.setSearchPreferences(new SearchPreferences());

        try {
            NetSuiteService ns = new NetSuiteServiceStub("https://"+passport.getAccount()+".suitetalk.api.netsuite.com/services/NetSuitePort_2019_1");
            try {
                try {
                    SearchResponseE se = ns.search(search, passport1, null, ai, pre, spe );
                    System.out.println(se.getSearchResponse().getSearchResult().getTotalRecords());
                } catch (ExceededConcurrentRequestLimitFault | ExceededRecordCountFault | ExceededRequestSizeFault
                        | ExceededUsageLimitFault e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } catch (AxisFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    private static EmployeeSearch createEmployeeSearch()
    {
        EmployeeSearchBasic employeeSearch = new EmployeeSearchBasic();
        SearchStringField emplEntityID = new SearchStringField();
        emplEntityID.setOperator(SearchStringFieldOperator.isNot);
        emplEntityID.setSearchValue("");
        employeeSearch.setEntityId(emplEntityID);

        RecordRef emplRec = new RecordRef();
        emplRec.setType(RecordType.employee);
        RecordRef[] emplRecArray = new RecordRef[1];
        emplRecArray[0] = emplRec;
        EmployeeSearch searchEmployee= new EmployeeSearch();
        searchEmployee.setBasic(employeeSearch);

        return searchEmployee;

    }

}

0 个答案:

没有答案