You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/07/16 11:31:46 UTC
svn commit: r964728 - in /camel/trunk/components/camel-cxf/src:
main/java/org/apache/camel/component/cxf/CxfEndpoint.java
test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java
Author: ningjiang
Date: Fri Jul 16 09:31:45 2010
New Revision: 964728
URL: http://svn.apache.org/viewvc?rev=964728&view=rev
Log:
CAMEL-2955 Add wrappedStyle option for camel-cxf endpoint
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java (with props)
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
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=964728&r1=964727&r2=964728&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 Jul 16 09:31:45 2010
@@ -83,7 +83,10 @@ public class CxfEndpoint extends Default
private String defaultOperationName;
private String defaultOperationNamespace;
private DataFormat dataFormat = DataFormat.POJO;
+ // This is for invoking the CXFClient with wrapped parameters of unwrapped parameters
private boolean isWrapped;
+ // This is for marshal or unmarshal message with the document-literal wrapped or unwrapped style
+ private Boolean wrappedStyle;
private boolean inOut = true;
private Bus bus;
private CxfBinding cxfBinding;
@@ -158,7 +161,12 @@ public class CxfEndpoint extends Default
if (getDataFormat() == DataFormat.PAYLOAD) {
sfb.setDataBinding(new HybridSourceDataBinding());
- }
+ }
+
+ // set the document-literal wrapped style
+ if (getWrappedStyle() != null) {
+ sfb.getServiceFactory().setWrapped(getWrappedStyle());
+ }
sfb.setBus(getBus());
sfb.setStart(false);
@@ -260,6 +268,11 @@ public class CxfEndpoint extends Default
factoryBean.getFeatures().add(new LoggingFeature());
}
+ // set the document-literal wrapped style
+ if (getWrappedStyle() != null) {
+ factoryBean.getServiceFactory().setWrapped(getWrappedStyle());
+ }
+
factoryBean.setBus(getBus());
}
@@ -295,6 +308,11 @@ public class CxfEndpoint extends Default
factoryBean.getFeatures().add(new LoggingFeature());
}
+ // set the document-literal wrapped style
+ if (getWrappedStyle() != null) {
+ factoryBean.getServiceFactory().setWrapped(getWrappedStyle());
+ }
+
factoryBean.setBus(getBus());
}
@@ -446,6 +464,14 @@ public class CxfEndpoint extends Default
public void setWrapped(boolean wrapped) {
isWrapped = wrapped;
}
+
+ public Boolean getWrappedStyle() {
+ return wrappedStyle;
+ }
+
+ public void setWrappedStyle(Boolean wrapped) {
+ wrappedStyle = wrapped;
+ }
public void setCxfBinding(CxfBinding cxfBinding) {
this.cxfBinding = cxfBinding;
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java?rev=964728&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java Fri Jul 16 09:31:45 2010
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.component.cxf;
+
+import org.apache.camel.CamelContext;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CxfSimpleRouterWithUnwrappedStyleTest extends CxfSimpleRouterTest {
+
+ private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS + "&wrappedStyle=false";
+ private String serviceEndpointURI = "cxf://" + SERVICE_ADDRESS + "?" + SERVICE_CLASS + "&wrappedStyle=false";
+
+ @BeforeClass
+ public static void startService() {
+ //start a service
+ ServerFactoryBean svrBean = new ServerFactoryBean();
+
+ svrBean.setAddress(SERVICE_ADDRESS);
+ svrBean.setServiceClass(HelloService.class);
+ svrBean.setServiceBean(new HelloServiceImpl());
+ svrBean.getServiceFactory().setWrapped(false);
+
+ server = svrBean.create();
+ server.start();
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ errorHandler(noErrorHandler());
+ from(routerEndpointURI).to("log:org.apache.camel?level=DEBUG").to(serviceEndpointURI);
+ }
+ };
+ }
+
+ protected HelloService getCXFClient() throws Exception {
+ ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
+ ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
+ clientBean.setAddress(SERVICE_ADDRESS);
+ clientBean.setServiceClass(HelloService.class);
+ clientBean.getServiceFactory().setWrapped(false);
+ HelloService client = (HelloService) proxyFactory.create();
+ return client;
+ }
+
+ @Test
+ public void testOnwayInvocation() throws Exception {
+ // ignore the invocation without parameter, as the document-literal doesn't support the invocation without parameter.
+ }
+
+}
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterWithUnwrappedStyleTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date