Author: ningjiang
Date: Fri Oct 8 04:26:41 2010
New Revision: 1005708
URL: http://svn.apache.org/viewvc?rev=1005708&view=rev
Log:
CAMEL-3190 Supporting to specify the publishedEndpointUrl for cxf:cxfEndpoint
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java?rev=1005708&r1=1005707&r2=1005708&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
Fri Oct 8 04:26:41 2010
@@ -26,6 +26,7 @@ import org.w3c.dom.Element;
import org.apache.camel.AsyncCallback;
import org.apache.camel.Processor;
import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.continuations.Continuation;
@@ -252,6 +253,9 @@ public class CxfConsumer extends Default
});
server = svrBean.create();
+ if (ObjectHelper.isNotEmpty(endpoint.getPublishedEndpointUrl())) {
+
server.getEndpoint().getEndpointInfo().setProperty("publishedEndpointUrl",
endpoint.getPublishedEndpointUrl());
+ }
}
@Override
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1005708&r1=1005707&r2=1005708&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Fri Oct 8 04:26:41 2010
@@ -88,6 +88,7 @@ public class CxfEndpoint extends Default
private boolean isWrapped;
// This is for marshal or unmarshal message with the document-literal
wrapped or unwrapped style
private Boolean wrappedStyle;
+ private String publishedEndpointUrl;
private boolean inOut = true;
private Bus bus;
private CxfBinding cxfBinding;
@@ -112,7 +113,7 @@ public class CxfEndpoint extends Default
protected void updateEndpointUri(String endpointUri) {
super.setEndpointUri(endpointUri);
}
-
+
public Producer createProducer() throws Exception {
Producer answer = new CxfProducer(this);
if (isSynchronous()) {
@@ -407,6 +408,14 @@ public class CxfEndpoint extends Default
public void setDataFormat(DataFormat format) {
dataFormat = format;
}
+
+ public String getPublishedEndpointUrl() {
+ return publishedEndpointUrl;
+ }
+
+ public void setPublishedEndpointUrl(String url) {
+ publishedEndpointUrl = url;
+ }
public String getWsdlURL() {
return wsdlURL;
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java?rev=1005708&r1=1005707&r2=1005708&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Fri Oct 8 04:26:41 2010
@@ -36,7 +36,9 @@ import org.junit.Test;
public class CxfConsumerTest extends CamelTestSupport {
protected static final String SIMPLE_ENDPOINT_ADDRESS =
"http://localhost:28080/test";
protected static final String SIMPLE_ENDPOINT_URI = "cxf://" +
SIMPLE_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.component.cxf.HelloService";
+ + "?serviceClass=org.apache.camel.component.cxf.HelloService"
+ + "&publishedEndpointUrl=http://www.simple.com/services/test";
+
private static final String ECHO_REQUEST = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body><ns1:echo
xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
+ "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">Hello
World!</arg0></ns1:echo></soap:Body></soap:Envelope>";
@@ -104,6 +106,12 @@ public class CxfConsumerTest extends Cam
String response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS,
ECHO_REQUEST, String.class);
assertTrue("Can't find the xml declaration.",
response.startsWith("<?xml version='1.0' encoding="));
}
+
+ @Test
+ public void testPublishEndpointUrl() throws Exception {
+ String response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS +
"?wsdl", null, String.class);
+ assertTrue("Can't find the right service location.",
response.indexOf("http://www.simple.com/services/test") > 0);
+ }