Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/pom.xml
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/pom.xml	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/pom.xml	(revision 47728)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet45-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-service-utils</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.2</version>
+	<scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/cnr-service-utils/tags/cnr-service-utils-1.0.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>apache</groupId>
+			<artifactId>oro</artifactId>
+			<version>2.0.8</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-frontend-jaxws</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>${mockito.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/deploy.info
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/deploy.info	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/deploy.info	(revision 47728)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/cnr-service-utils/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "cnr-service-utils"}
\ No newline at end of file
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/LocalServiceResolverImpl.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/LocalServiceResolverImpl.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/LocalServiceResolverImpl.java	(revision 47728)
@@ -0,0 +1,91 @@
+package eu.dnetlib.enabling.tools;
+
+import java.io.StringReader;
+import java.util.Map;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.xml.sax.InputSource;
+
+/**
+ * This service resolver parses the EPR and returns a local reference to a service instance if the EPR refers to the
+ * local node.
+ * 
+ * @author marko
+ * 
+ */
+public class LocalServiceResolverImpl extends AbstractServiceResolverImpl implements ServiceResolver, ApplicationContextAware {
+	private static final Log log = LogFactory.getLog(LocalServiceResolverImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private String baseAddress;
+
+	private ApplicationContext applicationContext;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.ServiceResolver#getService(java.lang.Class,
+	 *      javax.xml.ws.wsaddressing.W3CEndpointReference)
+	 */
+	@Override
+	public <T> T getService(final Class<T> clazz, final W3CEndpointReference epr) {
+
+		// backward compat
+		if (baseAddress == null) {
+			log.warn("please set baseAddress in " + this);
+			return null;
+		}
+
+		try {
+			// TODO: measure performance impact of this. I wrote it this way just to be sure of thread safety
+			String address = XPathFactory.newInstance().newXPath().evaluate("/*[local-name() ='EndpointReference']/*[local-name() = 'Address']",
+					new InputSource(new StringReader(epr.toString())));
+			if (log.isDebugEnabled())
+				log.debug("epr address " + address);
+			
+			if (address.startsWith(baseAddress))
+				return resolveLocalService(clazz, epr);
+		} catch (XPathExpressionException e) {
+			log.warn("cannot parse epr", e);
+		}
+
+		return null;
+	}
+
+	private <T> T resolveLocalService(final Class<T> clazz, W3CEndpointReference epr) {
+		log.debug("resolving local service " + clazz);
+
+		Map<String, T> services = (Map<String, T>) applicationContext.getBeansOfType(clazz, false, false);
+
+		log.debug("found services: " + services);
+		if(services.size() > 0)
+			for(T service : services.values())
+				return service;
+
+		return null;
+	}
+
+	public String getBaseAddress() {
+		return baseAddress;
+	}
+
+	public void setBaseAddress(String baseAddress) {
+		this.baseAddress = baseAddress;
+	}
+
+	public ApplicationContext getApplicationContext() {
+		return applicationContext;
+	}
+
+	@Override
+	public void setApplicationContext(ApplicationContext applicationContext) {
+		this.applicationContext = applicationContext;
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/JaxwsServiceResolverImpl.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/JaxwsServiceResolverImpl.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/JaxwsServiceResolverImpl.java	(revision 47728)
@@ -0,0 +1,25 @@
+package eu.dnetlib.enabling.tools;
+
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+/**
+ * This service resolver asks jaxws to obtain a proxy to a remote service.
+ *   
+ * @author marko
+ *
+ */
+public class JaxwsServiceResolverImpl extends AbstractServiceResolverImpl implements ServiceResolver {
+
+	/** 
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.ServiceResolver#getService(java.lang.Class, javax.xml.ws.wsaddressing.W3CEndpointReference)
+	 */
+	@Override
+	public <T> T getService(final Class<T> clazz, final W3CEndpointReference epr) {
+		synchronized(this) {
+			return epr.getPort(clazz, new WebServiceFeature[] {});
+		}
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/UniqueIdentifierGeneratorImpl.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/UniqueIdentifierGeneratorImpl.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/UniqueIdentifierGeneratorImpl.java	(revision 47728)
@@ -0,0 +1,74 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.UUID;
+
+/**
+ * generates unique UUID identifiers.
+ * 
+ * @author marko
+ * 
+ */
+public class UniqueIdentifierGeneratorImpl implements UniqueIdentifierGenerator {
+
+	/**
+	 * helps identify valid identifiers.
+	 */
+	public static final String UUID_REGEX = "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}";
+	
+	/**
+	 * prefixes all identifiers with this string.
+	 */
+	private String prefix = "";
+
+	/**
+	 * create a new instance with an empty prefix.
+	 */
+	public UniqueIdentifierGeneratorImpl() {
+		//
+	}
+
+	/**
+	 * construct a new instance with a given prefix.
+	 * 
+	 * @param prefix prefix
+	 */
+	public UniqueIdentifierGeneratorImpl(final String prefix) {
+		this.prefix = prefix;
+	}
+
+	public String getPrefix() {
+		return prefix;
+	}
+
+	public void setPrefix(final String prefix) {
+		this.prefix = prefix;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.UniqueIdentifierGenerator#generateIdentifier()
+	 */
+	@Override
+	public String generateIdentifier() {
+		return prefix + createUUID();
+	}
+
+	/**
+	 * the real job of creating the uuid is here.
+	 * 
+	 * @return new uuid
+	 */
+	private String createUUID() {
+		return UUID.randomUUID().toString();
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.UniqueIdentifierGenerator#getRegEx()
+	 */
+	@Override
+	public String getRegEx() {
+		return UUID_REGEX;
+	}
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/AbstractServiceResolverImpl.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/AbstractServiceResolverImpl.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/AbstractServiceResolverImpl.java	(revision 47728)
@@ -0,0 +1,32 @@
+package eu.dnetlib.enabling.tools;
+
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+/**
+ * implement common functionality of ServiceResolvers.
+ * 
+ * @author marko
+ *
+ */
+public abstract class AbstractServiceResolverImpl implements ServiceResolver {
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.ServiceResolver#getResourceIdentifier(javax.xml.ws.wsaddressing.W3CEndpointReference)
+	 */
+	@Override
+	public String getResourceIdentifier(final W3CEndpointReference epr) {
+		final DOMResult dom = new DOMResult();
+		epr.writeTo(dom);
+
+		try {
+			return XPathFactory.newInstance().newXPath().evaluate("//*[local-name() = 'ResourceIdentifier']", dom.getNode());
+		} catch (XPathExpressionException e) {
+			throw new IllegalStateException("cannot construct xpath expression", e);
+		} 
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ResourceLoaderHelper.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ResourceLoaderHelper.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ResourceLoaderHelper.java	(revision 47728)
@@ -0,0 +1,44 @@
+package eu.dnetlib.enabling.tools;
+
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternUtils;
+
+/**
+ * Some beans aren't directly instantiated (like quartz jobs for instance), so they cannot receive the resource loader
+ * by implementing the ResourceLoaderAware interface.
+ * 
+ * This class is a temporary solution to this problem until we find a way to obtain a bean reference to the
+ * application context (the actual resource loader) itself and inject it directly. It could be done by turning this
+ * class into a bean factory and expose the resource loader through it.   
+ * 
+ * @author marko
+ *
+ */
+public class ResourceLoaderHelper implements ResourceLoaderAware {
+
+	/**
+	 * injected resource loader.
+	 */
+	private ResourceLoader resourceLoader;
+
+	/**
+	 * obtain a resource pattern resolver for a given resource loader.
+	 * 
+	 * @return pattern resolver
+	 */
+	public ResourcePatternResolver getResourcePatternResolver() {
+		return ResourcePatternUtils.getResourcePatternResolver(getResourceLoader());
+	}
+	
+	public ResourceLoader getResourceLoader() {
+		return resourceLoader;
+	}
+
+	@Override
+	public void setResourceLoader(final ResourceLoader resourceLoader) {
+		this.resourceLoader = resourceLoader;
+	}
+	
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ResourceIdentifierResolver.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ResourceIdentifierResolver.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ResourceIdentifierResolver.java	(revision 47728)
@@ -0,0 +1,30 @@
+package eu.dnetlib.enabling.tools;
+
+/**
+ * Resource identifiers may carry, implicitly or explicity, some informations about the location of the resource in the
+ * hierarchical xmldb namespace.
+ * 
+ * Implementors of this interface may take different approachs to the problem.
+ * 
+ * @author marko
+ * 
+ */
+public interface ResourceIdentifierResolver {
+	/**
+	 * get the xmldb filename associated to this resource identifier, usually extracted from the identifier itself.
+	 * 
+	 * @param resId resource identifier
+	 * @return xmldb file name
+	 */
+	String getFileName(String resId);
+
+	/**
+	 * get the xmldb collection name associated to this resource identifier.
+	 * Implementors may decide to encode it in the identifier itself or use a secondary associative memory.
+	 * to quickly transform identifiers.
+	 * 
+	 * @param resId resource identifier
+	 * @return xmldb collection name
+	 */
+	String getCollectionName(String resId);
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/UniqueIdentifierGenerator.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/UniqueIdentifierGenerator.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/UniqueIdentifierGenerator.java	(revision 47728)
@@ -0,0 +1,25 @@
+package eu.dnetlib.enabling.tools;
+
+/**
+ * genrate unique identifiers.
+ * 
+ * @author marko
+ *
+ */
+public interface UniqueIdentifierGenerator {
+
+	/**
+	 * generate a new unique identifier.
+	 * 
+	 * @return string identifier
+	 */
+	String generateIdentifier();
+	
+	/**
+	 * helps identify valid identifiers.
+	 * 
+	 * @return string regex
+	 */
+	String getRegEx();
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ServiceResolver.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ServiceResolver.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/enabling/tools/ServiceResolver.java	(revision 47728)
@@ -0,0 +1,32 @@
+package eu.dnetlib.enabling.tools;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+/**
+ * Instances of this type resolve EPR references to service endpoints.
+ * 
+ * @author marko
+ * 
+ */
+public interface ServiceResolver {
+	/**
+	 * return a service client given an EPR instance.
+	 * 
+	 * @param <T>
+	 *            the service type
+	 * @param clazz
+	 *            needed for type inference of type parameter <T>
+	 * @param epr
+	 *            EPR
+	 * @return a service client reference
+	 */
+	<T> T getService(Class<T> clazz, W3CEndpointReference epr);
+
+	/**
+	 * Extract the resource identifier embedded in the EPR.
+	 * 
+	 * @param epr end point reference
+	 * @return resource identifier
+	 */
+	String getResourceIdentifier(W3CEndpointReference epr);
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/StandaloneCxfEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/StandaloneCxfEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/StandaloneCxfEndpointReferenceBuilder.java	(revision 47728)
@@ -0,0 +1,97 @@
+package eu.dnetlib.soap.cxf;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.endpoint.Endpoint;
+import org.springframework.beans.factory.annotation.Required;
+
+/**
+ * CxfEndpointReferenceBuilder is not able to create correct endpoint addresses outside a http request context. This means that service
+ * initialization code cannot obtain the service address and thus cannot register himself.
+ * 
+ * This subclass allows putting a local address (ip/dns + port) to be used when the runtime servlet context is not available.
+ * 
+ * TODO: automated tomcat port detection, trough org.apache.catalina.ServerFactory.getServer().getServices() TODO: automated jetty port
+ * detection
+ * 
+ * 
+ * @author marko
+ * 
+ */
+public class StandaloneCxfEndpointReferenceBuilder extends CxfEndpointReferenceBuilder {
+
+	private static final Log log = LogFactory.getLog(StandaloneCxfEndpointReferenceBuilder.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * base url where all services are exported.
+	 */
+	private String baseAddress;
+
+	private String absoluteBase;
+
+	private boolean forceLocalAddress = false;
+
+	public String getBaseAddress() {
+		return baseAddress;
+	}
+
+	public void setBaseAddress(final String baseAddress) {
+		this.baseAddress = baseAddress;
+	}
+
+	@PostConstruct
+	public void init() throws URISyntaxException {
+		URI base = new URI(baseAddress);
+		log.info("base address: " + baseAddress);
+
+		this.absoluteBase = (new URI(base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), null, null, null)).toString().trim();
+		log.info("absolute base address: " + absoluteBase);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.soap.cxf.CxfEndpointReferenceBuilder#getAddress(org.apache.cxf.endpoint.Endpoint)
+	 */
+	@Override
+	public String getAddress(final Endpoint endpoint) {
+		final String address = super.getAddress(endpoint);
+
+		if (forceLocalAddress) {
+			try {
+				URI uri = new URI(address);
+				if (!address.startsWith("http://")) {
+					String res = baseAddress + uri.getPath();
+					if (log.isDebugEnabled()) {
+						log.debug("fixing address to: " + res);
+					}
+					return res;
+				}
+				String res = absoluteBase + uri.getPath();
+				if (log.isDebugEnabled()) {
+					log.debug("forcing address to: " + res);
+				}
+				return res;
+			} catch (URISyntaxException e) {
+				throw new IllegalArgumentException(e);
+			}
+		}
+
+		if (!address.startsWith("http://") && (baseAddress != null)) { return baseAddress + address; }
+		return address;
+	}
+
+	public boolean isForceLocalAddress() {
+		return forceLocalAddress;
+	}
+
+	@Required
+	public void setForceLocalAddress(final boolean forceLocalAddress) {
+		this.forceLocalAddress = forceLocalAddress;
+	}
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/JaxwsEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/JaxwsEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/JaxwsEndpointReferenceBuilder.java	(revision 47728)
@@ -0,0 +1,64 @@
+package eu.dnetlib.soap.cxf;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.soap.AbstractEndpointReferenceBuilder;
+
+/**
+ * This EndpointReferenceBuilder implementation takes a jaxws endpoint and extracts the cxf endpoint from it.
+ *
+ * jaxws endpoints are the most readily available endpoint objects since they constructed from jaxws:endpoint spring
+ * beans, as shown in the CXF documentation.
+ *
+ * Since this implementation forwards the job to CxfEndpointReferenceBuilder, the 'builder' property has to be set:
+ *
+ * <pre>
+ * &lt;bean name=&quot;jaxwsEndpointReferenceBuilder&quot; class=&quot;eu.dnetlib.soap.cxf.JaxwsEndpointReferenceBuilder&quot;
+ *   p:builder-ref=&quot;cxfEndpointReferenceBuilder&quot; /&gt;
+ * </pre>
+ *
+ * @author marko
+ * @see CxfEndpointReferenceBuilder
+ *
+ */
+public class JaxwsEndpointReferenceBuilder extends AbstractEndpointReferenceBuilder<Endpoint> {
+
+	/**
+	 * required reference to the cxf endpoint builder.
+	 */
+	private CxfEndpointReferenceBuilder builder = null;
+
+	/**
+	 * simply unpacks the cxf endpoint from the jaxws endpoint and forwards it to CxfEndpointReferenceBuilder.
+	 *
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.util.Map)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(final Endpoint endpoint, final String referenceParam, final Map<QName, Object> attrs) {
+		return builder.getEndpointReference(((EndpointImpl) endpoint).getServer().getEndpoint(), referenceParam, attrs);
+	}
+
+	public CxfEndpointReferenceBuilder getBuilder() {
+		return builder;
+	}
+
+	@Required
+	public void setBuilder(final CxfEndpointReferenceBuilder builder) {
+		this.builder = builder;
+	}
+
+	@Override
+	public String getAddress(Endpoint endpoint) {
+		return builder.getAddress(((EndpointImpl) endpoint).getServer().getEndpoint());
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/CxfEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/CxfEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/cxf/CxfEndpointReferenceBuilder.java	(revision 47728)
@@ -0,0 +1,206 @@
+package eu.dnetlib.soap.cxf;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.oro.text.perl.Perl5Util;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import eu.dnetlib.soap.AbstractEndpointReferenceBuilder;
+
+/**
+ * The cxf endpoint is an internal cross-toolkit implementation of the messaging endpoint.
+ *
+ * <p>
+ * End users will normally access jaxws endpoints, since jaxws is the mostly used cxf frontend. However, generic code,
+ * like interceptors, will handle cxf endpoints, so sometimes you may need to construct endpoint references from them.
+ * </p>
+ *
+ * <pre>
+ * &lt;ns3:Address&gt;http://localhost:8090/app/services/isStore&lt;/ns3:Address&gt;
+ * &lt;ns3:ReferenceParameters/&gt;
+ * &lt;ns3:Metadata&gt;
+ *   &lt;wsaw:InterfaceName&gt;ns1:ISStoreService&lt;/wsaw:InterfaceName&gt;
+ *   &lt;wsaw:ServiceName EndpointName=&quot;ISStoreServicePort&quot;&gt;ns2:ISStoreServiceService&lt;/wsaw:ServiceName&gt;
+ *   &lt;infrastructure:infrastructure&gt;development&lt;/infrastructure:infrastructure&gt;
+ * &lt;/ns3:Metadata&gt;
+ * </pre>
+ *
+ * Users can easily define default system or service wide custom metadata to endpoint references by setting a
+ * defaultMetadata property:
+ *
+ * <pre>
+ * &lt;bean name=&quot;cxfEndpointReferenceBuilder&quot; class=&quot;eu.dnetlib.soap.cxf.CxfEndpointReferenceBuilder&quot;&gt;
+ *  &lt;property name=&quot;defaultMetadata&quot;&gt;
+ *   &lt;map&gt;
+ *    &lt;entry key=&quot;{http://dnetlib.eu/endpointReference}infrastructure&quot; value=&quot;${infrastructure.name}&quot; /&gt;
+ *   &lt;/map&gt;
+ *  &lt;/property&gt;
+ * &lt;/bean&gt;
+ * </pre>
+ *
+ *
+ * @author marko
+ *
+ */
+public class CxfEndpointReferenceBuilder extends AbstractEndpointReferenceBuilder<Endpoint> {
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(CxfEndpointReferenceBuilder.class); // NOPMD by marko on 11/24/08 4:55
+
+	/**
+	 * users can put some default metadata elements into all EPRs.
+	 */
+	private Map<String, Object> defaultMetadata;
+
+	/**
+	 * regexp utility.
+	 */
+	private final transient Perl5Util matcher = new Perl5Util();
+
+	/**
+	 * namespace of the ResourceIdentifier reference parameter.
+	 */
+	private String riNamespace = "http://www.driver.org";
+
+	/**
+	 * element name of the ResourceIdentifier reference parameter.
+	 */
+	private String riElementName = "ResourceIdentifier";
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * TODO: refactor.
+	 *
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.util.Map)
+	 */
+
+	@Override
+	public W3CEndpointReference getEndpointReference(final Endpoint endpoint, final String referenceParam, final Map<QName, Object> attributes) {
+		final String address = getAddress(endpoint);
+		return getEndpointReference(address, endpoint.getService().getName(), endpoint.getEndpointInfo().getName(), null, referenceParam,
+				attributes);
+	}
+
+	/**
+	 * low level method which allows the construction of a endpoint reference knowing all basic data as the address, service name etc.
+	 *
+	 * @param address
+	 * @param serviceName
+	 * @param endpointName
+	 * @param wsdl
+	 * @param referenceParam
+	 * @param attributes
+	 * @return
+	 */
+	public W3CEndpointReference getEndpointReference(
+			final String address,
+			final QName serviceName,
+			final QName endpointName,
+			final String wsdl,
+			final String referenceParam,
+			final Map<QName, Object> attributes) {
+		Map<QName, Object> attrs = attributes;
+
+		final W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+		builder.address(address);
+		if(serviceName != null)
+			builder.serviceName(serviceName);
+		if(endpointName != null)
+			builder.endpointName(endpointName);
+		builder.wsdlDocumentLocation(wsdl);
+
+		if (defaultMetadata != null) {
+			if (attrs == null)
+				attrs = new HashMap<QName, Object>();
+			for (Entry<String, Object> entry : defaultMetadata.entrySet())
+				attrs.put(splitQNameString(entry.getKey()), entry.getValue());
+		}
+
+		try {
+			final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); // NOPMD
+			if (referenceParam != null) {
+				final Element referenceElement = doc.createElementNS(getRiNamespace(), getRiElementName());
+				referenceElement.setTextContent(referenceParam);
+				builder.referenceParameter(referenceElement);
+			}
+
+			if (attrs != null && !attrs.isEmpty()) {
+				for (Entry<QName, Object> entry : attrs.entrySet()) {
+					final QName qname = entry.getKey();
+					final Element element = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
+					element.setTextContent((String) entry.getValue());
+					builder.metadata(element);
+				}
+			}
+		} catch (ParserConfigurationException e) {
+			log.fatal("cannot extend EPR", e);
+			throw new IllegalStateException("cannot extend EPR", e);
+		}
+
+		return builder.build();
+	}
+
+	/**
+	 * compute an endpoint address.
+	 *
+	 * @param endpoint
+	 *            endpoint
+	 * @return url as string
+	 */
+	@Override
+	public String getAddress(final Endpoint endpoint) {
+		return endpoint.getEndpointInfo().getAddress();
+	}
+
+	/**
+	 * helper method for converting "{namespace}elementName" strings to QNames.
+	 *
+	 * @param key
+	 *            "{namespace}elementName" string
+	 * @return qname
+	 */
+	private QName splitQNameString(final String key) {
+		matcher.match("m/{(.*)}(.*)/", key);
+
+		return new QName(matcher.group(1), matcher.group(2));
+	}
+
+	public Map<String, Object> getDefaultMetadata() {
+		return defaultMetadata;
+	}
+
+	public void setDefaultMetadata(final Map<String, Object> defaultMetadata) {
+		this.defaultMetadata = defaultMetadata;
+	}
+
+	public String getRiNamespace() {
+		return riNamespace;
+	}
+
+	public void setRiNamespace(final String riNamespace) {
+		this.riNamespace = riNamespace;
+	}
+
+	public String getRiElementName() {
+		return riElementName;
+	}
+
+	public void setRiElementName(final String riElementName) {
+		this.riElementName = riElementName;
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/EndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/EndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/EndpointReferenceBuilder.java	(revision 47728)
@@ -0,0 +1,96 @@
+package eu.dnetlib.soap;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+/**
+ * This is a generalization of org.apache.cxf.jaxws.EndpointReferenceBuilder and org.apache.cxf.jaxws.EndpointImpl
+ *
+ * <p>
+ * javax.xml.ws.WebServiceContext org.apache.cxf.jaxws.EndpointReferenceBuilder doesn't expose the API for adding
+ * additional metadata while org.apache.cxf.jaxws.EndpointImpl doesn't take the correct endpoint address from the
+ * EndpointInfo object. org.apache.cxf.endpoint.Endpoint return a CXF proprietary endpoint reference and not the
+ * javax/w3c standard definition.
+ * </p>
+ *
+ * <p>
+ * This interface is intended to provide an abstract way to construct an endpoint reference for a given service,
+ * depending on the type of endpoint interface you have at hand (CXF abstract endpoint or jaxws endpoint)
+ * </p>
+ *
+ * <p>
+ * Normally the type parameter T will be bound to your endpoint type.
+ * </p>
+ *
+ * <p>
+ * In CXF jaxws applications you can easly get a WebServiceContext instance which returns an EndpointReference, however
+ * the API is cumbersome because it requires instantiating w3c DOM Element instances for each reference parameter, and
+ * it doesn't allow setting custom metadata elements.
+ * </p>
+ *
+ * <p>
+ * Implementors of this API will extract as many useful informations from the runtime besides the plain soap endpoint
+ * address.
+ * </p>
+ *
+ * @author marko
+ * @param <T>
+ *            all endpoint builders are parameterized to specific endpoint type which on the used framework (not on the
+ *            service)
+ *
+ */
+public interface EndpointReferenceBuilder<T> {
+	/**
+	 * get an endpoint reference with default metadata attached.
+	 *
+	 * @param endpoint
+	 *            the endpoint
+	 * @return an endpoint reference
+	 */
+	W3CEndpointReference getEndpointReference(T endpoint);
+
+	/**
+	 * get an endpoint reference with custom metadata attached.
+	 *
+	 * @param endpoint
+	 *            the endpoint
+	 * @param attrs
+	 *            metadata attribute map
+	 * @return an endpoint reference
+	 */
+	W3CEndpointReference getEndpointReference(T endpoint, Map<QName, Object> attrs);
+
+	/**
+	 * get an endpoint reference with a WSA reference parameter.
+	 *
+	 * @param endpoint
+	 *            the endpoint
+	 * @param referenceParam
+	 *            reference parameters
+	 * @return an endpoint reference
+	 */
+	W3CEndpointReference getEndpointReference(T endpoint, String referenceParam);
+
+	/**
+	 * get an endpoint reference with custom metadata attached and WSA reference parameter.
+	 *
+	 * @param endpoint
+	 *            endpoint
+	 * @param referenceParam
+	 *            reference parameters
+	 * @param attrs
+	 *            metadata attribute map
+	 * @return an endpoint reference
+	 */
+	W3CEndpointReference getEndpointReference(T endpoint, String referenceParam, Map<QName, Object> attrs);
+
+	/**
+	 * Sometimes we need only the address.
+	 *
+	 * @param endpoint endpoint
+	 * @return address
+	 */
+	String getAddress(T endpoint);
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/AbstractEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/AbstractEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/AbstractEndpointReferenceBuilder.java	(revision 47728)
@@ -0,0 +1,46 @@
+package eu.dnetlib.soap;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+/**
+ *
+ * default implementation short methods.
+ *
+ * @author marko
+ *
+ * @param <T>
+ */
+public abstract class AbstractEndpointReferenceBuilder<T> implements EndpointReferenceBuilder<T> {
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint) {
+		return getEndpointReference(endpoint, (Map<QName, Object>)null);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.lang.String)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint, final String referenceParam) {
+		return getEndpointReference(endpoint, referenceParam, null);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.util.Map)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint, final Map<QName, Object> attrs) {
+		return getEndpointReference(endpoint, null, attrs);
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/StaticEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/StaticEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/java/eu/dnetlib/soap/StaticEndpointReferenceBuilder.java	(revision 47728)
@@ -0,0 +1,60 @@
+package eu.dnetlib.soap;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+
+/**
+ * This endpoint reference builder builds always the same epr, with a fixed address, for any incoming endpoint (even
+ * null endpoints). Useful when registering service profiles for external services like the old perl Aggregator.
+ *
+ * @author marko
+ *
+ * @param <T>
+ *            endpoint type
+ */
+public class StaticEndpointReferenceBuilder<T> implements EndpointReferenceBuilder<T> {
+
+	/**
+	 * service address.
+	 */
+	private String address;
+
+	@Override
+	public String getAddress(final T endpoint) {
+		return address;
+	}
+
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint) {
+		final W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+		builder.address(address);
+		return builder.build();
+	}
+
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint, final Map<QName, Object> attrs) {
+		return getEndpointReference(endpoint);
+	}
+
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint, final String referenceParam) {
+		return getEndpointReference(endpoint);
+	}
+
+	@Override
+	public W3CEndpointReference getEndpointReference(final T endpoint, final String referenceParam, final Map<QName, Object> attrs) {
+		return getEndpointReference(endpoint);
+	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(final String address) {
+		this.address = address;
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/resources/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.properties
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/resources/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.properties	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/resources/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.properties	(revision 47728)
@@ -0,0 +1 @@
+transport.soap.force.local.address=false
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/resources/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/resources/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/main/resources/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml	(revision 47728)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+	<bean id="jaxwsEndpointReferenceBuilder" class="eu.dnetlib.soap.cxf.JaxwsEndpointReferenceBuilder"
+		p:builder-ref="cxfEndpointReferenceBuilder" />
+
+	<bean id="cxfEndpointReferenceBuilder"
+		class="eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder"
+		p:baseAddress="${transport.soap.baseAddress}"
+		p:forceLocalAddress="${transport.soap.force.local.address}">
+		<property name="defaultMetadata">
+			<map>
+				<entry key="{http://dnetlib.eu/endpointReference}infrastructure"
+					value="${infrastructure.name}" />
+			</map>
+		</property>
+	</bean>
+
+</beans>
\ No newline at end of file
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/test/java/eu/dnetlib/soap/cxf/StandaloneCxfEndpointReferenceBuilderTest.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/test/java/eu/dnetlib/soap/cxf/StandaloneCxfEndpointReferenceBuilderTest.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/test/java/eu/dnetlib/soap/cxf/StandaloneCxfEndpointReferenceBuilderTest.java	(revision 47728)
@@ -0,0 +1,74 @@
+package eu.dnetlib.soap.cxf;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+/**
+ * test StandaloneCxfEndpointReferenceBuilderTest.
+ * 
+ * @author marko
+ * 
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class StandaloneCxfEndpointReferenceBuilderTest extends CxfEndpointReferenceBuilderTest {
+
+	/**
+	 * some constant url prefix.
+	 */
+	private static final String HTTP_TEST_COM = "http://test.com";
+
+	/**
+	 * class under test.
+	 */
+	private transient StandaloneCxfEndpointReferenceBuilder builder;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.soap.cxf.CxfEndpointReferenceBuilderTest#setUp()
+	 */
+	@Override
+	@Before
+	public void setUp() {
+		super.setUp();
+		builder = new StandaloneCxfEndpointReferenceBuilder();
+	}
+
+	/**
+	 * test computeAddress.
+	 */
+	@Test
+	public void testGetAddress() {
+		assertEquals("no base, http", "http://localhost/something", builder.getAddress(getEndpoint()));
+
+		when(getEndpointInfo().getAddress()).thenReturn("/localPath");
+		assertEquals("no base, no http", "/localPath", builder.getAddress(getEndpoint()));
+
+		builder.setBaseAddress("http://somebase");
+		assertEquals("base, no http", "http://somebase/localPath", builder.getAddress(getEndpoint()));
+	}
+
+	/**
+	 * make code coverage happy.
+	 */
+	@Test
+	public void testGetBaseAddress() {
+		builder.setBaseAddress(HTTP_TEST_COM);
+		assertEquals("testing setter", HTTP_TEST_COM, builder.getBaseAddress());
+	}
+
+	/**
+	 * make code coverage happy.
+	 */
+	@Test
+	public void testSetBaseAddress() {
+		builder.setBaseAddress(HTTP_TEST_COM);
+		assertEquals("testing setter", HTTP_TEST_COM, builder.getBaseAddress());
+	}
+
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/test/java/eu/dnetlib/soap/cxf/CxfEndpointReferenceBuilderTest.java
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/test/java/eu/dnetlib/soap/cxf/CxfEndpointReferenceBuilderTest.java	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2/src/test/java/eu/dnetlib/soap/cxf/CxfEndpointReferenceBuilderTest.java	(revision 47728)
@@ -0,0 +1,126 @@
+package eu.dnetlib.soap.cxf;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.EndpointReference;
+
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+/**
+ * test the CxfEndpointReferenceBuilder.
+ *
+ * @author marko
+ *
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class CxfEndpointReferenceBuilderTest {
+
+	/**
+	 * service mock.
+	 */
+	@Mock
+	private Service service;
+
+	/**
+	 * endpoint info mock.
+	 */
+	@Mock
+	private EndpointInfo endpointInfo;
+
+	/**
+	 * endpoint mock.
+	 */
+	@Mock
+	private Endpoint endpoint;
+
+	/**
+	 * object under test.
+	 */
+	private CxfEndpointReferenceBuilder builder;
+
+	/**
+	 * initialize object under test and prepare a commmon endpoint mock.
+	 */
+	@Before
+	public void setUp() {
+		builder = new CxfEndpointReferenceBuilder();
+		when(service.getName()).thenReturn(new QName("http://my.test", "TestService"));
+
+		when(endpoint.getEndpointInfo()).thenReturn(endpointInfo);
+		when(endpoint.getService()).thenReturn(service);
+		when(endpointInfo.getAddress()).thenReturn("http://localhost/something");
+		when(endpointInfo.getName()).thenReturn(new QName("http://my.test", "TestServiceEndpoint"));
+	}
+
+	/**
+	 * test.
+	 */
+	@Test
+	public void testGetEndpointReference() {
+
+		final EndpointReference epr = builder.getEndpointReference(endpoint);
+		assertTrue("check serialization", epr.toString().contains("TestServiceEndpoint"));
+		assertTrue("check serialization", epr.toString().contains("http://localhost/something"));
+		assertTrue("check serialization", epr.toString().contains("http://my.test"));
+
+	}
+
+	/**
+	 * test method.
+	 */
+	@Test
+	public void testGetEndpointReferenceMetadata() {
+		final HashMap<String, Object> defaultMetadata = new HashMap<String, Object>();
+		defaultMetadata.put("{http://someuri}somename", "somevalue");
+		builder.setDefaultMetadata(defaultMetadata);
+
+		final EndpointReference epr = builder.getEndpointReference(endpoint);
+		
+		assertTrue("check serialization", epr.toString().contains("somename xmlns=\"http://someuri\""));
+		assertTrue("check serialization", epr.toString().contains("xmlns=\"http://someuri\""));
+		assertTrue("check serialization", epr.toString().contains("somevalue"));
+	}
+
+	protected Service getService() {
+		return service;
+	}
+
+	protected void setService(final Service service) {
+		this.service = service;
+	}
+
+	protected EndpointInfo getEndpointInfo() {
+		return endpointInfo;
+	}
+
+	protected void setEndpointInfo(final EndpointInfo endpointInfo) {
+		this.endpointInfo = endpointInfo;
+	}
+
+	protected Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	protected void setEndpoint(final Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	protected CxfEndpointReferenceBuilder getBuilder() {
+		return builder;
+	}
+
+	protected void setBuilder(final CxfEndpointReferenceBuilder builder) {
+		this.builder = builder;
+	}
+}
Index: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2
===================================================================
--- modules/cnr-service-utils/tags/cnr-service-utils-1.0.2	(nonexistent)
+++ modules/cnr-service-utils/tags/cnr-service-utils-1.0.2	(revision 47728)

Property changes on: modules/cnr-service-utils/tags/cnr-service-utils-1.0.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+target
+.project
+.settings
+*.iml
