You are here: Customers and Contacts > searchCustomers

Search Customers

Description

Search customers/view all customers for the given query parameters.

This Web service is available for both contact login and ISV login.

Default Protocol Method Type URI
HTTPS GET searchCustomers.xml

Query Parameters

Parameter Description Valid Values Optional
customerName Specify the customer name. String Yes
customerRefId The unique reference ID of the customer. String Yes
refId Reference ID. String Yes
pageIndex The starting page number.

Integer (>0)

Yes
pageSize

The number of customers retrieved by one request.

Its default value can be configured from EMS Admin Console by using the Max Records Per Response (Web Services) property.

Integer (>0)

Yes
sortCol Sort against the column.

String (crmId, cstmrId, customerName, refId, status)

Default Value: cstmrId

Yes
sortOrder The order to sort.

String (asc, desc)

Default Value:desc

Yes
lastModified Creation or modification time stamp.

Long

Yes
contactEmailId The e-mail ID of customer's contact. String Yes

Sample Code

import java.io.IOException;
import java.net.URLDecoder;

//..............................
//..............................
//..............................
import org.apache.http.params.HttpParams;
public class EMSSample {
                private static DefaultHttpClient httpclient = new DefaultHttpClient();
                private static Principal principal = null;
                private static StringBuffer query;
                //..............................
                //..............................
                //..............................
public static String searchCustomers.xml()throws Exception  {
    if(!verifyLogin()){
                return "login failed";
    }
    HttpContext context = new BasicHttpContext();
    context.setAttribute(ClientContext.USER_TOKEN, principal);
         HttpGet get = new HttpGet("https://localhost:8443/ems/searchCustomers.xml");
    query = new StringBuffer();
    setParameter("customerName", "");
    setParameter("lastModified", "");
    setParameter("customerRefId", "");
    setParameter("sortOrder", "");
    setParameter("refId", "");
    setParameter("pageSize", "");
    setParameter("sortCol", "");
    setParameter("contactEmailId", "");
    setParameter("pageIndex", "");
    get.setURI(new URI(URLDecoder.decode(get.getURI() + query.toString(),"UTF-8")));
    HttpResponse response = httpclient.execute(get, context);
    HttpEntity entity = response.getEntity();
    byte[] b = null;
    if (entity != null) {
        long l = entity.getContentLength();
         b = new byte[(int) l];
         entity.getContent().read(b);
         entity.consumeContent();
                }
                return new String(b);
                }
    static void setParameter(String key, String value) {
                if (query.toString().equals("")) {
                                query.append("?" + key + "=" + value + "&");
                } else {
                                query.append(key + "=" + value + "&");
                }
    }
    }

Sample Response

<emsResponse>
  <customers>
    <customer>
      <creationTime>1334808889000</creationTime>
      <customerId>1</customerId>
      <customerName>Alaska</customerName>
      <customerRefId>alaska</customerRefId>
      <desc />
      <enabled>true</enabled>
      <modificationTime>1334808889000</modificationTime>
      <refId />
      <timezone>(GMT-09:00) Alaska</timezone>
    </customer>
  </customers>
  <stat>ok</stat>
  <total>1</total>
</emsResponse>
See Also:

Output Format for Failure

Error Codes

Error Code Description
100 Invalid request parameter.
101 You are not authorized to use this service.
102 Invalid data entered.
107 An internal error occurred! Please report the error to System administrator.
109 The sort order value is not valid. Specify asc or desc.
110 The page index value is not valid. Specify any positive integer value greater than 0.
111 The page size value is not valid. Specify any positive integer value greater than 0.
124 Invalid sortColumn. Valid values are startdate, enddate, state, status, contactemailid, customername, id.
128 You should log on first.
132 The URL address does not exist.
1080 {field} should be of dataType long. [Note: This error code is applicable for the field - lastModified.]
1081 Invalid Web service version provided
1084 No Web service version provided
1088 The EMS system is running on HTTPS. Please provide the correct Web service URL.
1177 No contact exists for the given emailId.
1178 No customer associated with the given emailId.