You are here: Catalog Elements > Namespace > addNamespace

Add Namespace

Description

Adds a new namespace to EMS.

Default Protocol Method Type URI
HTTPS POST addNamespace.xml

Post Parameters

Parameter Description Valid Values Optional
namespaceName The namespace name. String No
namespaceDescription Description of the namespace. String Yes
refId1 Information that uniquely identifies the namespace in a different ERP system. String Yes
refId2 A second unique reference ID, similar to Ref ID 1. String Yes

Sample Code

import java.io.IOException;
//..............................
//..............................
//..............................
import org.apache.http.params.HttpParams;
public class EMSSample {
   private static DefaultHttpClient httpclient = new DefaultHttpClient();
   private static Principal principal = null;
   //..............................
   //..............................
   //..............................
   public static String addNamespace.xml()throws Exception {
      if(!verifyLogin()){
         return "login failed";
      }
      HttpContext context = new BasicHttpContext();
      context.setAttribute(ClientContext.USER_TOKEN, principal);
      HttpPost post = new HttpPost("https://localhost:8080/ems/3.6/addNamespace.xml");
      List<NameValuePair> nvps = new ArrayList<NameValuePair>();
      nvps.add(new BasicNameValuePair("namespaceName", ""));
      nvps.add(new BasicNameValuePair("refId2", ""));
      nvps.add(new BasicNameValuePair("refId1", ""));
      nvps.add(new BasicNameValuePair("namespaceDescription", ""));
      post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
      HttpResponse response = httpclient.execute(post, 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);
   }
}

Sample Response

<?xml version=”1.0” encoding=”UTF-8”?>
<emsResponse >
   <namespaceId>4</namespaceId>
   <stat>ok</stat>
</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.
107 An internal error occurred! Please report the error to System administrator.
115 Length of {field} is {actual value}. It cannot be more Than {max value}. [Note: This error code is applicable for the fields - billAddr, billAddrCity, billAddrCountry, billAddrState, billAddrZip, shipAddr, shipAddrCity, shipAddrCountry, shipAddrState, shipAddrZip, refId1, refId2, contactPassword, description, and default value.]
122 {field} is a required field and should have a not null value. [Note: This error code is applicable for the fields - Eid, namespaceName, featureName, startDate, endDate, userIds, featureId, productName, productVersion, detailsLM, lmId, templateType, customAttribute, lineItemId, customerRefId, granularity, loginId, oldPassword, and newPassword.]
128 You should log on first.
132 The URL address does not exist.
321 Namespace EMS_NMS already exists. Please try again with different name
1021 Please enter a valid value.
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.