Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Referencing custom core services with the Commerce Manager Client

Referencing custom core services with the Commerce Manager Client

Warning: Build order and dependency resolution

To avoid build-time dependency resolution issues, you need to ensure the extension core is built before referencing custom services with the Commerce Manager Client.

If your CM client plugins needs to reference new or modified services in the core library extension, you need to do the following:

  1. Create a fragment for the com.elasticpath.cmclient.core plugin.
  2. Create a plugin-remote.xml file in the fragment's META-INF\conf directory.
  3. Add the service proxy bean definitions for the custom services to plugin-remote.xml.
  4. Add a HTTP proxy definition for the new service in ep-cmserver-plugin.xml.

For example, your core library extension defines a custom attribute service named com.extensions.service.attribute.ExtAttributeService. In com.elasticpath.cmclient.core/conf/spring/service/serviceCMClient, the service proxy bean for the out-of-the-box attributeService is defined as follows:

            com.elasticpath.cmclient.core/src/main/resources/spring/service/serviceCMClient.xml
	<bean id="attributeService" class="com.elasticpath.cmclient.core.AuditHttpInvokerProxyFactoryBean">
		<property name="serviceUrl">
			<value>attributeService.remote</value>
		</property>
		<property name="serviceInterface">
  			<value>com.elasticpath.service.attribute.AttributeService</value>
  		</property>
	</bean>

         
  1. In your fragment's plugin-remote.xml, your new service proxy bean definition might look similar to the following:
    <bean id="attributeService" class="com.elasticpath.cmclient.core.EpHttpInvokerProxyFactoryBean">
        <property name="serviceUrl">
            <value>attributeService.remote</value>
        </property>
        <property name="serviceInterface">
            <!-- reference custom service in core library extension: -->
            <value>com.extensions.service.attribute.ExtAttributeService</value>
        </property>
    </bean>
    
  2. In the Commerce Manager server's extension project, create an HTTP proxy definition for the new service in ep-cmserver-plugin.xml.
    <bean id="httpAttributeService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    	<property name="service">
    		<ref bean="attributeService"/commerce-legacy/>
    	</property>
    	<property name="serviceInterface">
    		<value>com.extensions.service.attribute.ExtAttributeService</value>
    	</property>
    </bean>
    
  3. If you are creating a new service, not overriding an existing one, the mappings property of the SimpleUrlHandlerMapping bean must include the URL to the new service mapping in ep-cmserver-plugin.xml. For example, if attributeService is a new service, we add the following:
    <bean id="SimpleUrlHandlerMapping" 
    		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
    		parent="AbstractSimpleUrlHandlerMapping">
    	<property name="mappings">
    		<props>
    			<prop key="/commerce-legacy/attributeService.remote">httpAttributeService</prop>
    		</props>
    	</property>
    </bean>