cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r530745 - in /incubator/cxf/trunk: rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/ tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/exp...
Date Fri, 20 Apr 2007 11:28:19 GMT
Author: mmao
Date: Fri Apr 20 04:28:18 2007
New Revision: 530745

URL: http://svn.apache.org/viewvc?view=rev&rev=530745
Log:
CXF-559
RefelectionServiceBuilderFactory does support wsdl fault in case of the method just throw
an subclass of Exception

Modified:
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/calculator.wsdl
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/hello_soap12.wsdl
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/expected_hello_world_doc_lit.wsdl

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=530745&r1=530744&r2=530745
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Fri Apr 20 04:28:18 2007
@@ -57,6 +57,7 @@
 import org.apache.cxf.service.invoker.FactoryInvoker;
 import org.apache.cxf.service.invoker.Invoker;
 import org.apache.cxf.service.invoker.LocalFactory;
+import org.apache.cxf.service.model.AbstractMessageContainer;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.FaultInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
@@ -350,7 +351,7 @@
             createMessageParts(intf, uOp, m);
             
             if (uOp.hasInput()) {
-                MessageInfo msg = new MessageInfo(op, uOp.getInput().getName());        
       
+                MessageInfo msg = new MessageInfo(op, uOp.getInput().getName());
                 op.setInput(uOp.getInputName(), msg);
                 
                 createInputWrappedMessageParts(uOp, m, msg);
@@ -374,6 +375,16 @@
             }
             
             for (FaultInfo fault : uOp.getFaults()) {
+                Class expClz = (Class) fault.getProperty(Class.class.getName());
+                if (Exception.class.isAssignableFrom(getBeanClass(expClz))) {
+                    QName name = uOp.getFault(fault.getFaultName()).getName();
+                    FaultInfo faultInfo = new FaultInfo(name, name, op);
+                    faultInfo.setProperty("unwrapped.fault.info", fault);
+                    faultInfo.setProperty(Class.class.getName(), fault.getProperty(Class.class.getName()));
+                    op.addFault(faultInfo);
+                    
+                    createFaultWrappedMessageParts(faultInfo);
+                }
                 for (MessagePartInfo p : fault.getMessageParts()) {
                     p.setConcreteName(p.getName());
                 }
@@ -419,13 +430,27 @@
                             .getOutput(), wraperBeanName);
                     }
                 }
+                
+                if (!op.getFaults().isEmpty()) {
+                    for (FaultInfo faultInfo : op.getFaults()) {
+                        Class expClz = (Class) faultInfo.getProperty(Class.class.getName());
+                        if (Exception.class.isAssignableFrom(getBeanClass(expClz))) {
+                            createWrappedSchema(serviceInfo,
+                                                faultInfo,
+                                                (FaultInfo) faultInfo.getProperty("unwrapped.fault.info"),
+                                                faultInfo.getFaultName());
+                        }
+                    }
+                }                
             }
         }
 
     }
 
-    protected void createWrappedSchema(ServiceInfo serviceInfo, MessageInfo wrappedMessage,
-                                       MessageInfo unwrappedMessage, QName wraperBeanName)
{
+    protected void createWrappedSchema(ServiceInfo serviceInfo,
+                                       AbstractMessageContainer wrappedMessage,
+                                       AbstractMessageContainer unwrappedMessage,
+                                       QName wraperBeanName) {
         SchemaInfo schemaInfo = null;
         for (SchemaInfo s : serviceInfo.getSchemas()) {
             if (s.getNamespaceURI().equals(wraperBeanName.getNamespaceURI())) {
@@ -556,8 +581,9 @@
         
         
     }
- 
-    private void createWrappedMessageSchema(MessageInfo wrappedMessage, MessageInfo unwrappedMessage,
+    
+    private void createWrappedMessageSchema(AbstractMessageContainer wrappedMessage,
+                                            AbstractMessageContainer unwrappedMessage,
                                             XmlSchema schema) {
         XmlSchemaElement el = new XmlSchemaElement();
         el.setQName(wrappedMessage.getName());
@@ -662,6 +688,14 @@
         initializeFaults(intf, op, method);
     }
 
+    protected void createFaultWrappedMessageParts(FaultInfo fault) {
+        MessagePartInfo part = fault.addMessagePart("fault");
+        part.setElement(true);
+        if (part.getElementQName() == null) {
+            part.setElementQName(fault.getFaultName());
+        }
+    }
+        
     protected void createInputWrappedMessageParts(OperationInfo op, Method method, MessageInfo
inMsg) {
         MessagePartInfo part = inMsg.addMessagePart(op.getInputName());
         part.setElement(true);
@@ -905,12 +939,21 @@
 
     protected FaultInfo addFault(final InterfaceInfo service, final OperationInfo op, Class
exClass) {
         Class beanClass = getBeanClass(exClass);
-        
+
         QName faultName = getFaultName(service, op, exClass, beanClass);
         FaultInfo fi = op.addFault(faultName, faultName);
         fi.setProperty(Class.class.getName(), exClass);
+
         
         MessagePartInfo mpi = fi.addMessagePart(faultName);
+
+        if (Exception.class.isAssignableFrom(beanClass)) {
+            beanClass = String.class;
+            mpi.setName(new QName(faultName.getNamespaceURI(), "message"));
+            mpi.setTypeQName(new QName("http://www.w3.org/2001/XMLSchema", "string"));
+            fi.setProperty("unwrapped.fault.info", fi);
+        }
+        
         mpi.setTypeClass(beanClass);
         
         return fi;

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?view=diff&rev=530745&r1=530744&r2=530745
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Fri Apr 20 04:28:18 2007
@@ -39,9 +39,10 @@
     JavaToProcessor processor = new JavaToProcessor();
     private WSDLHelper wsdlHelper = new WSDLHelper();
 
-//         @org.junit.After
-//         public void tearDown() {
-//         }
+    @org.junit.After
+    public void tearDown() {
+        super.tearDown();
+    }
         
     @Test
     public void testGetWSDLVersion() {

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/calculator.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/calculator.wsdl?view=diff&rev=530745&r1=530744&r2=530745
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/calculator.wsdl
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/calculator.wsdl
Fri Apr 20 04:28:18 2007
@@ -35,6 +35,13 @@
 </xsd:sequence>
 </xsd:complexType>
 </xsd:element>
+<xsd:element name="AddException">
+<xsd:complexType>
+<xsd:sequence>
+<xsd:element name="message" nillable="true" type="xsd:string"/>
+</xsd:sequence>
+</xsd:complexType>
+</xsd:element>
 </xsd:schema>
   </wsdl:types>
   <wsdl:message name="add">
@@ -46,7 +53,7 @@
     </wsdl:part>
   </wsdl:message>
   <wsdl:message name="AddException">
-    <wsdl:part name="AddException">
+    <wsdl:part name="fault" element="ns1:AddException">
     </wsdl:part>
   </wsdl:message>
   <wsdl:portType name="CalculatorPortType">

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/hello_soap12.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/hello_soap12.wsdl?view=diff&rev=530745&r1=530744&r2=530745
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/hello_soap12.wsdl
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/hello_soap12.wsdl
Fri Apr 20 04:28:18 2007
@@ -1,4 +1,22 @@
 <?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.
+-->
 <wsdl:definitions name="GreeterService" targetNamespace="http://apache.org/hello_world_soap12_http"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://apache.org/hello_world_soap12_http"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://apache.org/hello_world_soap12_http/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
   <wsdl:types>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://apache.org/hello_world_soap12_http/types"
version="1.0">

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/expected_hello_world_doc_lit.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/expected_hello_world_doc_lit.wsdl?view=diff&rev=530745&r1=530744&r2=530745
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/expected_hello_world_doc_lit.wsdl
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/expected_hello_world_doc_lit.wsdl
Fri Apr 20 04:28:18 2007
@@ -1,3 +1,4 @@
+<?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
@@ -16,7 +17,6 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<?xml version="1.0" encoding="UTF-8"?>
 <wsdl:definitions name="GreeterService" targetNamespace="http://apache.org/hello_world_doc_lit"
xmlns:ns1="http://apache.org/hello_world_doc_lit" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://apache.org/hello_world_doc_lit/types" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
   <wsdl:types>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://apache.org/hello_world_doc_lit/types"
version="1.0">



Mime
View raw message