diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/AppServletContextListener.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/AppServletContextListener.java
index c76ed8f..6ceb9a2 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/AppServletContextListener.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/AppServletContextListener.java
@@ -25,13 +25,13 @@
     @Override
     public void contextInitialized(ServletContextEvent eventData)
     {
-        MsbRegister.handleMsbRegistration();
+        //MsbRegister.handleMsbRegistration();
     }
 
     @Override
     public void contextDestroyed(ServletContextEvent eventData)
     {
-        MsbRegister.handleMsbUnRegistration();
+        //MsbRegister.handleMsbUnRegistration();
     }
 }
 
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java
deleted file mode 100644
index 1b05af1..0000000
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.vnfsdk.marketplace.msb;
-
-import org.onap.vnfsdk.marketplace.common.CommonConstant;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MsbRegister
-{
-    private static final Logger logger = LoggerFactory.getLogger(MsbRegister.class);
-
-    private MsbRegister() {
-    }
-
-    /**
-     * Interface top handle MSB Registration
-     */
-    public static void handleMsbRegistration()
-    {
-        logger.info("VNF-SDK Market Place microservice register start.");
-        int retry = 0;
-        while(CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRIES >= retry)
-        {
-            int retCode = MsbRegistration.getInstance().register();
-
-            if(CommonConstant.MsbRegisterCode.MSDB_REGISTER_SUCESS != retCode)
-            {
-                logger.warn("microservice register failed, try again after(ms):" + CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRY_SLEEP);
-                threadSleep(CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRY_SLEEP);
-            }
-            else
-            {
-                if(CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS == retCode)
-                {
-                    logger.info("microservice register failed, MSB Register File Not Exists !");
-                }
-                else
-                {
-                    logger.info("microservice register success !");
-                }
-                break;
-            }
-
-            retry++;
-            logger.info("VNF-SDK Market Place microservice register [retry count]:" + retry);
-        }
-        logger.info("VNF-SDK Market Place microservice register end.");
-    }
-
-    public static void handleMsbUnRegistration()
-    {
-        logger.info("VNF-SDK Market Place microservice handleMsbUnRegistration Start.");
-        MsbRegistration.getInstance().unRegister();
-        logger.info("VNF-SDK Market Place microservice handleMsbUnRegistration end.");
-    }
-
-    private static void threadSleep(int second)
-    {
-        try
-        {
-            Thread.sleep(second);
-        }
-        catch(InterruptedException error)
-        {
-            logger.error("thread sleep error.errorMsg:", error);
-            Thread.currentThread().interrupt();
-        }
-    }
-}
-
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegistration.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegistration.java
deleted file mode 100644
index 4c1344d..0000000
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegistration.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.vnfsdk.marketplace.msb;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.onap.vnfsdk.marketplace.common.CommonConstant;
-import org.onap.vnfsdk.marketplace.common.JsonUtil;
-import org.onap.vnfsdk.marketplace.rest.RestResponse;
-import org.onap.vnfsdk.marketplace.rest.RestfulClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class MsbRegistration {
-    private static final Logger LOGGER = LoggerFactory.getLogger(MsbRegistration.class);
-
-    private static MsbRegistration oMsbRegistration = new MsbRegistration();
-
-    private static final String MSB_REGISTION_FILE = "etc/microservice/marketplace_rest.json";
-    private static final String MSB_REGISTION_URL = "/onapapi/microservices/v1/services?createOrUpdate=false";
-    private static final String MSB_UN_REGISTION_URL = "/onapapi/microservices/v1/services/{0}/version/{1}/nodes/{2}/{3}";
-    private static final String NODES = "nodes";
-    private static final String IP = "ip";
-    private static final String PORT = "port";
-    private static final String SERVICE_NAME = "serviceName";
-    private static final String VERSION = "version";
-
-    private boolean bRegistrationStatus = false;
-
-    private MsbRegistration () {
-    }
-
-    public static MsbRegistration getInstance()
-    {
-        return oMsbRegistration;
-    }
-    /**
-     * Interface to handle MSB Registration
-     * @return
-     */
-    public int register()
-    {
-        File file = new File(MSB_REGISTION_FILE);
-        if(!file.exists())
-        {
-            LOGGER.info("Stop registering as can't find msb registion file:" + file.getAbsolutePath());
-            return CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS;
-        }
-
-        Map<?, ?> msbRegistionBodyMap = getMsbRegistrationData();
-        if(null == msbRegistionBodyMap)
-        {
-            LOGGER.info("Reading data from msb registion file failed:" + file.getAbsolutePath());
-            return CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS;
-        }
-
-        LOGGER.info("Registering body: " + JsonUtil.toJson(msbRegistionBodyMap));
-
-        bRegistrationStatus = sendRequest(msbRegistionBodyMap);
-
-        return bRegistrationStatus
-                ? CommonConstant.MsbRegisterCode.MSDB_REGISTER_SUCESS
-                        : CommonConstant.MsbRegisterCode.MSDB_REGISTER_FAILED;
-    }
-
-    private Map<?, ?> getMsbRegistrationData()
-    {
-        Map<?, ?> msbRegistionBodyMap = null;
-        try
-        {
-            ObjectMapper mapper = new ObjectMapper();
-            byte[] bytes = Files.readAllBytes(Paths.get(MSB_REGISTION_FILE));
-            msbRegistionBodyMap = mapper.readValue(bytes, Map.class);
-
-            replaceLocalIp(msbRegistionBodyMap);
-        }
-        catch(IOException e)
-        {
-            LOGGER.error("Failed to get microservice bus registration body, " + e);
-        }
-        return msbRegistionBodyMap;
-    }
-
-    /**
-     * Send MSB Registration request
-     * @param msbRegistionBodyMap
-     * @return
-     */
-    private boolean sendRequest(Map<?, ?> msbRegistionBodyMap)
-    {
-        LOGGER.info("Start registering to microservice bus");
-        String rawData = JsonUtil.toJson(msbRegistionBodyMap);
-        MsbDetails oMsbDetails =  MsbDetailsHolder.getMsbDetails();
-        if(null == oMsbDetails) {
-            LOGGER.info("MSB Details is NULL , Registration Failed !!!");
-            return false;
-        }
-        RestResponse oResponse = RestfulClient.sendPostRequest(oMsbDetails.getDefaultServer().getHost(),
-                                oMsbDetails.getDefaultServer().getPort(),
-                                MSB_REGISTION_URL, rawData);
-
-        if(null == oResponse){
-            LOGGER.info("Null Unregister Response for  " + MSB_REGISTION_URL);
-            return false;
-        }
-        LOGGER.info("Response Code Received for MBS Registration:" + oResponse.getStatusCode());
-        return isSuccess(oResponse.getStatusCode()) ? true : false;
-    }
-
-    public int unRegister()
-    {
-        if(!bRegistrationStatus){
-            return CommonConstant.MsbRegisterCode.MSDB_REGISTER_SUCESS;
-        }
-
-        MsbDetails oMsbDetails =  MsbDetailsHolder.getMsbDetails();
-        if(null == oMsbDetails){
-            LOGGER.info("MSB Details is NULL , Registration Failed !!!");
-            return CommonConstant.MsbRegisterCode.MSDB_REGISTER_FAILED;
-        }
-
-        File file = new File(MSB_REGISTION_FILE);
-        if(!file.exists()){
-            LOGGER.info("Stop registering as can't find msb registion file:" + file.getAbsolutePath());
-            return CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS;
-        }
-
-        try {
-            Map<?, ?> msbRegistionBodyMap = getMsbRegistrationData();
-
-            String serviceName = (String)msbRegistionBodyMap.get(SERVICE_NAME);
-            String version = (String)msbRegistionBodyMap.get(VERSION);
-
-            @SuppressWarnings("unchecked")
-            List<Map<String, String>> nodes = (List<Map<String, String>>)msbRegistionBodyMap.get(NODES);
-
-            Map<String, String> node = nodes.get(0);
-            String ip = node.get(IP);
-            String port = node.get(PORT);
-
-            String url = MessageFormat.format(MSB_UN_REGISTION_URL, serviceName, version, ip, port);
-            LOGGER.info("Start Unregister to microservice bus, url: " + url);
-
-            RestResponse oResponse = RestfulClient.delete(oMsbDetails.getDefaultServer().getHost(),
-                                        Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),url);
-
-            if(null == oResponse) {
-                LOGGER.info("Null Unregister Response for  " + url);
-                return CommonConstant.MsbRegisterCode.MSDB_REGISTER_FAILED;
-            }
-            LOGGER.info("Unregister Response " + oResponse.getStatusCode());
-            return isSuccess(oResponse.getStatusCode()) ?
-                    CommonConstant.MsbRegisterCode.MSDB_REGISTER_SUCESS :
-                        CommonConstant.MsbRegisterCode.MSDB_REGISTER_FAILED;
-        } catch(NullPointerException e) {
-            LOGGER.info("Readed data is Invalid from msb registion file:" + file.getAbsolutePath(), e);
-            return CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS;
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void replaceLocalIp(Map<?, ?> msbRegistionBodyMap)
-    {
-        List<Map<String, String>> nodes = (List<Map<String, String>>)msbRegistionBodyMap.get(NODES);
-        Map<String, String> node = nodes.get(0);
-        if(StringUtils.isNotEmpty(node.get(IP))) {
-            return;
-        }
-
-        try
-        {
-            InetAddress addr = InetAddress.getLocalHost();
-            String ipAddress = addr.getHostAddress();
-            node.put(IP, ipAddress);
-
-            LOGGER.info("Local ip: " + ipAddress);
-        }
-        catch(UnknownHostException e)
-        {
-            LOGGER.error("Unable to get IP address, " + e);
-        }
-    }
-
-    private boolean isSuccess(int httpCode)
-    {
-        return (httpCode == 200 || httpCode == 201) ? true : false;
-    }
-}
-
