Java – List Accounts by Default


package com.z2systems.cxfclient.samples.account;

import com.z2systems.schemas.account.*;
import com.z2systems.schemas.common.OperationResult;
import com.z2systems.schemas.common.Page;
import com.z2systems.schemas.neonws.AccountService;
import com.z2systems.schemas.neonws.Neonws;
import org.junit.Test;

import javax.xml.namespace.QName;
import java.net.MalformedURLException;
import java.net.URL;

public class ListAccountsByDefault {

    private static final QName SERVICE_NAME = new QName("http://www.z2systems.com/schemas/neonws/", "Neonws");

    @Test
    public void listAccountByDefaultTest() {

        URL wsdlURL = null;
        try {
            wsdlURL = new URL("https://api.neoncrm.com/neonws/services/AccountService?wsdl");

        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        Neonws ss = new Neonws(wsdlURL, SERVICE_NAME);
        AccountService port = ss.getAccountPort();

        ListAccountsByDefaultRequest request = new ListAccountsByDefaultRequest();

        //construct list account search criteria
        AccountSearchCriteria searchCriteria = new AccountSearchCriteria();
        searchCriteria.setFirstName("John");

        //construct page object
        Page page = new Page();
        page.setPageSize(50L);
        page.setCurrentPage(1L);

        request.setPage(page);
        request.setAccountSearchCriteria(searchCriteria);
        request.setUserSessionId("T1357615747419");
        ListAccountsByDefaultResponse response = port.listAccountsByDefault(request);

        if (response != null) {

            System.out.println(response.getOperationResult().toString());

            if (OperationResult.SUCCESS.equals(response.getOperationResult())) {

                System.out.println(response.getSearchResults());
            } else {
                System.out.println(response.getErrors());
            }
        }

    }

}