This is an Apache CXF SOAP service example with JiBX databinding. The approach is quite similar to the maven-jibx-plugin Webservice example (except from the OSGi usage) but it also uses a class-decorator (SerializableDecorator
) to extend the generated classes with a java.io.Serializable
interface.
The class-decorator usage is defined in the /src/main/config/custom-jibx-codegen.xml
file.
The project is build using maven and the following plugins:
The cxf-codegen-plugin provides the possibility to choose JiBX as databinding but it does not provide the possibility to define the code generation customization (class-decorator). So the code generation of the xsd types is excluded from the cxf-codegen-plugin section and a schema-codegen
goal is added in the jibx-maven-plugin section (what would normally not be necessary).
If you run the project (de.frvabe.sample.calculator.Main.class
) the wsdl of the service will be accessible at
http://localhost:8080/calculator?wsdl
The service provides a simple calculator operation ignoring most mathematical rules ;-)
So if you send the following request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://calculator.sample.frvabe.de/types">
<soapenv:Header/>
<soapenv:Body>
<typ:term>
<part>
<value>1</value>
</part>
<part>
<operator>ADD</operator>
<value>2</value>
</part>
<part>
<operator>MULTIPLY</operator>
<value>3</value>
</part>
<part>
<operator>DIVIDE</operator>
<value>4</value>
</part>
<part>
<operator>SUBTRACT</operator>
<value>5</value>
</part>
</typ:term>
</soapenv:Body>
</soapenv:Envelope>
You will get the result
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<types:result xmlns:types="http://calculator.sample.frvabe.de/types">
<value>-2.75</value>
</types:result>
</soap:Body>
</soap:Envelope>
By the way - the project was compiled and run successful using the lates OpenJDK 8 build b84 SNAPSHOT.