cxf: web-services-spring-jaxb2-client, WSDL with Fault messages
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 20 Dec 2015 01:11:09 +0000 (02:11 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 20 Dec 2015 01:11:09 +0000 (02:11 +0100)
cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl
cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd
cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd
cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd

index 02b2256..5094a3a 100644 (file)
@@ -1,14 +1,33 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://gumartinm.name/spring-ws/example" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://gumartinm.name/resource/wsdl/schemas" targetNamespace="http://gumartinm.name/resource/wsdl/schemas">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://gumartinm.name/spring-ws/example" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://gumartinm.name/resource/wsdl/schemas" targetNamespace="http://gumartinm.name/resource/wsdl/schemas">
   <wsdl:types>
     <xs:schema xmlns:annox="http://annox.dev.java.net" xmlns:example="http://gumartinm.name/spring-ws/example" xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:parent="http://gumartinm.name/spring-ws/parent" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" jaxb:extensionBindingPrefixes="inheritance annox" jaxb:version="2.1" targetNamespace="http://gumartinm.name/spring-ws/example">
+    
+    <!--
+         When should an item be declared as an element versus when should it be defined as a type?
+         When in doubt, make it a type. You can always create an element from the type, if needed. With a type, other elements can reuse that type.
+         
+         <xs:all> specifies that the child elements can appear in any order.
+         
+         <xs:sequence> specifies child elements can only appear in the order mentioned.
+    -->
 
     <!--
         We are going to use catalog.cat in order to avoid downloading parent.xsd from remote server
+        when creating Java objects from examples.xsd.
     -->
     <xs:import namespace="http://gumartinm.name/spring-ws/parent" schemaLocation="http://gumartinm.name/spring-ws/parent/parent.xsd"/>
 
 
+       <!-- Spring requires the following:
+            1. XSD elements being used as request must end with Request name.
+            2. XSD elements being used as response must end with Response name.
+
+                IN THIS WAY SPRING FINDS OUT HOW TO CREATE THE wsdl:operation IN THE AUTOGENERATED WSDL.
+                
+                ExampleRequest and ExampleResponse will be associated to the wsdl:operation Example in the autogenerated wsdl and
+                the wsdl:operation Example will have the wsdl:request ExampleRequest and wsdl:response ExampleResponse  elements.
+                The same for CustomBindingExample.
+       -->
        <!-- Using inheritance and annox plugin -->
        <xs:element name="ExampleRequest">
           <xs:complexType>
@@ -19,7 +38,7 @@
                 </xs:appinfo>
             </xs:annotation>   
             <xs:all>
-                <xs:element name="data" type="xs:string"/>
+                <xs:element name="data" type="parent:limitedString"/>
             </xs:all>
         </xs:complexType>
        </xs:element>
             </xs:all>
         </xs:complexType>
     </xs:element>
+    <xs:element name="ExampleFault">
+       <xs:complexType>
+               <xs:sequence>
+                       <xs:element name="technicalError" type="xs:string"/>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="elements" type="parent:element"/>
+               </xs:sequence>
+        </xs:complexType>
+    </xs:element>
 
 
        <!-- Using custombinding.xjb instead of inheritance plugin.
             </xs:all>
         </xs:complexType>
     </xs:element>
+    <xs:element name="CustomBindingExampleFault">
+       <xs:complexType>
+               <xs:sequence>
+                       <xs:element name="technicalError" type="xs:string"/>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="elements" type="parent:element"/>
+               </xs:sequence>
+        </xs:complexType>
+    </xs:element>
 
        <!-- Example of creating array list by means of XSD -->
     <xs:complexType name="car">
 
 </xs:schema>
   </wsdl:types>
+  <wsdl:message name="ExampleFault">
+    <wsdl:part element="sch:ExampleFault" name="ExampleFault">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="CustomBindingExampleFault">
+    <wsdl:part element="sch:CustomBindingExampleFault" name="CustomBindingExampleFault">
+    </wsdl:part>
+  </wsdl:message>
   <wsdl:message name="CustomBindingExampleRequest">
     <wsdl:part element="sch:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
     </wsdl:part>
     </wsdl:part>
   </wsdl:message>
   <wsdl:portType name="Examples">
-    <wsdl:operation name="CustomBindingExample">
-      <wsdl:input message="tns:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
-    </wsdl:input>
-      <wsdl:output message="tns:CustomBindingExampleResponse" name="CustomBindingExampleResponse">
-    </wsdl:output>
-    </wsdl:operation>
     <wsdl:operation name="Example">
       <wsdl:input message="tns:ExampleRequest" name="ExampleRequest">
     </wsdl:input>
       <wsdl:output message="tns:ExampleResponse" name="ExampleResponse">
     </wsdl:output>
+      <wsdl:fault message="tns:ExampleFault" name="ExampleFault">
+    </wsdl:fault>
+    </wsdl:operation>
+    <wsdl:operation name="CustomBindingExample">
+      <wsdl:input message="tns:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
+    </wsdl:input>
+      <wsdl:output message="tns:CustomBindingExampleResponse" name="CustomBindingExampleResponse">
+    </wsdl:output>
+      <wsdl:fault message="tns:CustomBindingExampleFault" name="CustomBindingExampleFault">
+    </wsdl:fault>
     </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="ExamplesSoap12" type="tns:Examples">
     <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
-    <wsdl:operation name="CustomBindingExample">
+    <wsdl:operation name="Example">
       <soap12:operation soapAction=""/>
-      <wsdl:input name="CustomBindingExampleRequest">
+      <wsdl:input name="ExampleRequest">
         <soap12:body use="literal"/>
       </wsdl:input>
-      <wsdl:output name="CustomBindingExampleResponse">
+      <wsdl:output name="ExampleResponse">
         <soap12:body use="literal"/>
       </wsdl:output>
+      <wsdl:fault name="ExampleFault">
+        <soap12:fault name="ExampleFault" use="literal"/>
+      </wsdl:fault>
     </wsdl:operation>
-    <wsdl:operation name="Example">
+    <wsdl:operation name="CustomBindingExample">
       <soap12:operation soapAction=""/>
-      <wsdl:input name="ExampleRequest">
+      <wsdl:input name="CustomBindingExampleRequest">
         <soap12:body use="literal"/>
       </wsdl:input>
-      <wsdl:output name="ExampleResponse">
+      <wsdl:output name="CustomBindingExampleResponse">
         <soap12:body use="literal"/>
       </wsdl:output>
+      <wsdl:fault name="CustomBindingExampleFault">
+        <soap12:fault name="CustomBindingExampleFault" use="literal"/>
+      </wsdl:fault>
     </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="ExamplesService">
     <wsdl:port binding="tns:ExamplesSoap12" name="ExamplesSoap12">
-      <soap12:address location="http://localhost:8080/web-services-spring-server/spring-ws/example"/>
+      <soap12:address location="http://localhost:8080/web-services-spring-jaxb2-server/spring-ws/example"/>
     </wsdl:port>
   </wsdl:service>
-</wsdl:definitions>
+</wsdl:definitions>
\ No newline at end of file
index 96c3737..e73313a 100644 (file)
@@ -9,13 +9,33 @@
     jaxb:extensionBindingPrefixes="inheritance annox"
     elementFormDefault="qualified"
     targetNamespace="http://gumartinm.name/spring-ws/example">
+    
+    <!--
+         When should an item be declared as an element versus when should it be defined as a type?
+         When in doubt, make it a type. You can always create an element from the type, if needed. With a type, other elements can reuse that type.
+         
+         <xs:all> specifies that the child elements can appear in any order.
+         
+         <xs:sequence> specifies child elements can only appear in the order mentioned.
+    -->
 
     <!--
         We are going to use catalog.cat in order to avoid downloading parent.xsd from remote server
+        when creating Java objects from examples.xsd.
     -->
     <xs:import namespace="http://gumartinm.name/spring-ws/parent" schemaLocation="http://gumartinm.name/spring-ws/parent/parent.xsd" />
 
 
+       <!-- Spring requires the following:
+            1. XSD elements being used as request must end with Request name.
+            2. XSD elements being used as response must end with Response name.
+
+                IN THIS WAY SPRING FINDS OUT HOW TO CREATE THE wsdl:operation IN THE AUTOGENERATED WSDL.
+                
+                ExampleRequest and ExampleResponse will be associated to the wsdl:operation Example in the autogenerated wsdl and
+                the wsdl:operation Example will have the wsdl:request ExampleRequest and wsdl:response ExampleResponse  elements.
+                The same for CustomBindingExample.
+       -->
        <!-- Using inheritance and annox plugin -->
        <xs:element name="ExampleRequest">
           <xs:complexType>
@@ -26,7 +46,7 @@
                 </xs:appinfo>
             </xs:annotation>   
             <xs:all>
-                <xs:element name="data" type="xs:string" />
+                <xs:element name="data" type="parent:limitedString" />
             </xs:all>
         </xs:complexType>
        </xs:element>
             </xs:all>
         </xs:complexType>
     </xs:element>
+    <xs:element name="ExampleFault">
+       <xs:complexType>
+               <xs:sequence>
+                       <xs:element name="technicalError" type="xs:string" />
+                       <xs:element name="elements" type="parent:element" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+        </xs:complexType>
+    </xs:element>
 
 
        <!-- Using custombinding.xjb instead of inheritance plugin.
             </xs:all>
         </xs:complexType>
     </xs:element>
+    <xs:element name="CustomBindingExampleFault">
+       <xs:complexType>
+               <xs:sequence>
+                       <xs:element name="technicalError" type="xs:string" />
+                       <xs:element name="elements" type="parent:element" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+        </xs:complexType>
+    </xs:element>
 
        <!-- Example of creating array list by means of XSD -->
     <xs:complexType name="car">
index 3c340a4..46f6550 100644 (file)
@@ -1,8 +1,18 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xmlns:parent="http://gumartinm.name/spring-ws/parent"
     elementFormDefault="qualified"
     targetNamespace="http://gumartinm.name/spring-ws/parent">
        
+    <!--
+         When should an item be declared as an element versus when should it be defined as a type?
+         When in doubt, make it a type. You can always create an element from the type, if needed. With a type, other elements can reuse that type.
+         
+         <xs:all> specifies that the child elements can appear in any order.
+         
+         <xs:sequence> specifies child elements can only appear in the order mentioned.
+    -->
+       
     <xs:simpleType name="parentEnumType">
         <xs:restriction base="xs:token">
             <xs:enumeration value="FIRST"/>
     
     <xs:simpleType name="limitedString">
        <xs:restriction base="xs:string">
-               <xs:maxLength value="20" />
+               <xs:maxLength value="30" />
        </xs:restriction>
        </xs:simpleType>
+       
+       <xs:complexType name="element">
+        <xs:sequence>
+            <xs:element name="message" type="xs:string"/>
+            <xs:element name="messageArgs" type="xs:string" minOccurs="0" maxOccurs="100"/>
+        </xs:sequence>
+    </xs:complexType>
 
 </xs:schema>
index 8b4bb95..e73313a 100644 (file)
@@ -9,6 +9,15 @@
     jaxb:extensionBindingPrefixes="inheritance annox"
     elementFormDefault="qualified"
     targetNamespace="http://gumartinm.name/spring-ws/example">
+    
+    <!--
+         When should an item be declared as an element versus when should it be defined as a type?
+         When in doubt, make it a type. You can always create an element from the type, if needed. With a type, other elements can reuse that type.
+         
+         <xs:all> specifies that the child elements can appear in any order.
+         
+         <xs:sequence> specifies child elements can only appear in the order mentioned.
+    -->
 
     <!--
         We are going to use catalog.cat in order to avoid downloading parent.xsd from remote server
             </xs:all>
         </xs:complexType>
     </xs:element>
+    <xs:element name="ExampleFault">
+       <xs:complexType>
+               <xs:sequence>
+                       <xs:element name="technicalError" type="xs:string" />
+                       <xs:element name="elements" type="parent:element" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+        </xs:complexType>
+    </xs:element>
 
 
        <!-- Using custombinding.xjb instead of inheritance plugin.
             </xs:all>
         </xs:complexType>
     </xs:element>
+    <xs:element name="CustomBindingExampleFault">
+       <xs:complexType>
+               <xs:sequence>
+                       <xs:element name="technicalError" type="xs:string" />
+                       <xs:element name="elements" type="parent:element" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+        </xs:complexType>
+    </xs:element>
 
        <!-- Example of creating array list by means of XSD -->
     <xs:complexType name="car">