You are here: Catalog Elements > Product > searchProducts

Search Products

Description

Retrieve the list of products against the query parameters.

Default Protocol Method Type URI
HTTPS GET searchProducts.xml

Query Parameters

Parameter Description Valid Values Optional
productName Specify the product name. String Yes
productVersion Version of the product. String Yes
namespaceName Specify the namespace to which the product belongs. String Yes
sortCol Sort against the column.

String (productName, productVersion, namespaceName, productDescription, lifeCycleSatge, deployed)

Default Value:productName

Yes
sortOrder The order to sort.

String (asc, desc)

Default Value: desc

Yes
pageSize

The number of products 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
pageIndex The starting page number.

Integer (>0)

Default Value: 1

Yes
refId1 Information that uniquely identifies the Product in a different system, for example, a Product ID in your company's ERP system. String Yes
refId2 A second unique reference ID, similar to Ref ID 1. String Yes
lastModified Creation or Modification time stamp. Long 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 searchProducts.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/3.6/searchProducts.xml");
		query = new StringBuffer();
		setParameter("namespaceName", "char");
		setParameter("refId2", "Pref2");
		setParameter("lastModified", "1327379905000");
		setParameter("refId1", "Pref1");
		setParameter("sortOrder", "asc");
		setParameter("pageSize", "1");
		setParameter("sortCol", "productName");
		setParameter("productVersion", "v1");
		setParameter("productName", "P1");
		setParameter("pageIndex", "1");
		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

<?xml version="1.0" encoding="UTF-8"?>
<emsResponse>
   <products>
      <product>
         <creationTime>1426137147000</creationTime>
         <deployed>true</deployed>
         <desc />
         <id>3</id>
         <lifeCycleStage>Complete</lifeCycleStage>
         <modificationTime>1426139580000</modificationTime>
         <name>Pnew</name>
         <namespaceId>1</namespaceId>
         <namespaceName>test36</namespaceName>
         <refId1 />
         <refId2 />
         <saId>1</saId>
         <ver>3</ver>
      </product>
   </products>
   <stat>ok</stat>
   <total>1</total>
</emsResponse>
See Also:

Output Format for Failure

Error Codes

Error Code Description
100 Invalid request parameter.
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.
120 {field} value is less than the minimum permitted value {value}. [Note: This error code is applicable for the fields - productd, featureId,entId, billType, lmId, lastModified, timeZoneId, customerId, and granularity.]
128 You should log on first.
132 The URL address does not exist.
133 Invalid namespace.
322 This Namespace does not exists in the system.
1039 The sort column is not valid. Valid values are productId,productName,productVersion,lifeCycleStage,deployed,namespaceName,productDescription.
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.