You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/01/07 07:40:49 UTC
svn commit: r732240 - in
/servicemix/components/bindings/servicemix-cxf-bc/trunk/src:
main/java/org/apache/servicemix/cxfbc/
test/java/org/apache/servicemix/cxfbc/provider/
test/resources/org/apache/servicemix/cxfbc/provider/
Author: ffang
Date: Tue Jan 6 22:40:48 2009
New Revision: 732240
URL: http://svn.apache.org/viewvc?rev=732240&view=rev
Log:
[SM-1758]cxf provider should be able to extract operationName based on payload and wsdl if using doc/literal style in case that no operationName bound to the MessageExchange
Added:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml (with props)
Modified:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=732240&r1=732239&r2=732240&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Tue Jan 6 22:40:48 2009
@@ -16,6 +16,7 @@
*/
package org.apache.servicemix.cxfbc;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
@@ -37,8 +38,10 @@
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMSource;
@@ -48,15 +51,20 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
import com.ibm.wsdl.Constants;
import org.apache.cxf.Bus;
import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.SoapVersion;
import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.model.SoapBodyInfo;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.catalog.OASISCatalogManager;
import org.apache.cxf.endpoint.Client;
@@ -76,6 +84,7 @@
import org.apache.cxf.phase.PhaseInterceptorChain;
import org.apache.cxf.phase.PhaseManager;
import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingMessageInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.OperationInfo;
@@ -96,6 +105,7 @@
import org.apache.servicemix.cxfbc.interceptors.MtomCheckInterceptor;
import org.apache.servicemix.cxfbc.interceptors.JbiFault;
import org.apache.servicemix.cxfbc.interceptors.CxfJbiConstants;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.soap.util.DomUtil;
import org.springframework.core.io.Resource;
@@ -178,9 +188,8 @@
if (ei.getBinding().getOperations().size() == 1) {
boi = ei.getBinding().getOperations().iterator().next();
} else {
- throw new Fault(new Exception(
- "Operation not bound on this MessageExchange"));
-
+ boi = findOperation(nm, message, boi, exchange);
+ cxfExchange.put(MessageExchange.class, exchange);
}
} else {
boi = ei.getBinding().getOperation(exchange.getOperation());
@@ -493,6 +502,56 @@
}
}
+ private BindingOperationInfo findOperation(NormalizedMessage nm,
+ Message message,
+ BindingOperationInfo boi,
+ MessageExchange exchange)
+ throws TransformerException, ParserConfigurationException, IOException, SAXException {
+ //try to figure out the operationName based on the incoming message
+ //payload and wsdl if use doc/literal/wrapped
+ Element element = new SourceTransformer().toDOMElement(nm.getContent());
+
+ if (!useJBIWrapper) {
+ SoapVersion soapVersion = ((SoapMessage)message).getVersion();
+ if (element != null) {
+ Element bodyElement = (Element) element.getElementsByTagNameNS(
+ element.getNamespaceURI(),
+ soapVersion.getBody().getLocalPart()).item(0);
+ if (bodyElement != null) {
+ element = (Element) bodyElement.getFirstChild();
+ }
+ }
+ } else {
+ element = DomUtil.getFirstChildElement(DomUtil.getFirstChildElement(element));
+ }
+
+ QName opeName = new QName(element.getNamespaceURI(), element.getLocalName());
+ SoapBindingInfo binding = (SoapBindingInfo) ei.getBinding();
+ for (BindingOperationInfo op : binding.getOperations()) {
+ String style = binding.getStyle(op.getOperationInfo());
+ if (style == null) {
+ style = binding.getStyle();
+ }
+ if ("document".equals(style)) {
+ BindingMessageInfo msg = op.getInput();
+ if (msg.getExtensor(SoapBodyInfo.class)
+ .getParts().get(0).getElementQName().equals(opeName)) {
+ boi = op;
+ exchange.setOperation(new QName(boi.getName().getNamespaceURI(), opeName.getLocalPart()));
+ break;
+ }
+ } else {
+ throw new Fault(new Exception(
+ "Operation must bound on this MessageExchange if use rpc mode"));
+ }
+ }
+ if (boi == null) {
+ throw new Fault(new Exception(
+ "Operation not bound on this MessageExchange"));
+ }
+ return boi;
+ }
+
@Override
public void start() throws Exception {
applyFeatures();
@@ -645,5 +704,5 @@
public List<AbstractFeature> getFeatures() {
return features;
}
-
+
}
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java?rev=732240&r1=732239&r2=732240&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java Tue Jan 6 22:40:48 2009
@@ -148,6 +148,11 @@
serversStarted = false;
}
+ public void testGreetMeProviderWithJBIWrapperWithoutOperationName() throws Exception {
+ setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml");
+ greetMeProviderWithoutOperationNameTestBase();
+ }
+
public void testGreetMeProviderWithOutJBIWrapper() throws Exception {
setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
greetMeProviderTestBase(false);
@@ -189,7 +194,6 @@
io = client.createInOutExchange();
io.setService(new QName("http://apache.org/hello_world_soap_http_provider", "SOAPService"));
io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http_provider", "Greeter"));
- io.setOperation(new QName("http://apache.org/hello_world_soap_http_provider", "greetMe"));
//send message to proxy
io.getInMessage().setContent(new StringSource(
"<greetMe xmlns='http://apache.org/hello_world_soap_http_provider/types'><requestType>"
@@ -204,6 +208,27 @@
assertTrue(txt.indexOf("Hello Edell") >= 0);
}
+
+ private void greetMeProviderWithoutOperationNameTestBase() throws Exception {
+ client = new DefaultServiceMixClient(jbi);
+ io = client.createInOutExchange();
+ io.setService(new QName("http://apache.org/hello_world_soap_http_provider", "SOAPService"));
+ io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http_provider", "Greeter"));
+ //send message to proxy
+ io.getInMessage().setContent(new StringSource(
+ "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ + "<part> "
+ + "<greetMe xmlns='http://apache.org/hello_world_soap_http_provider/types'><requestType>"
+ + "ffang"
+ + "</requestType></greetMe>"
+ + "</part>"
+ + "</message>"));
+
+ client.sendSync(io);
+
+ assertTrue(new SourceTransformer().contentToString(
+ io.getOutMessage()).indexOf("Hello ffang") >= 0);
+ }
private void greetMeProviderJmsTestBase(boolean sync, String name) throws Exception {
Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml?rev=732240&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml (added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml Tue Jan 6 22:40:48 2009
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+ xmlns:test="urn:test"
+ xmlns:greeter="http://apache.org/hello_world_soap_http_provider">
+
+
+ <sm:container id="jbi" embedded="true">
+
+ <sm:endpoints>
+
+ <cxfbc:provider wsdl="./hello_world.wsdl"
+ locationURI="http://localhost:9000/SoapContext/SoapPort"
+ endpoint="SoapPort"
+ service="greeter:SOAPService"
+ interfaceName="greeter:Greeter"
+ >
+ <cxfbc:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfbc:inInterceptors>
+ <cxfbc:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfbc:outInterceptors>
+ <cxfbc:inFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfbc:inFaultInterceptors>
+ <cxfbc:outFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfbc:outFaultInterceptors>
+ </cxfbc:provider>
+ </sm:endpoints>
+
+ </sm:container>
+
+</beans>
Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml