Configuring the cxf-se-su service unit
Wiki Markup |
---|
{scrollbar} |
On this page, we are going to
Excerpt |
---|
configure the cxf-se-su service unit to provide our service webservice |
Configuring the pom.xml
Changing the project name
In order to make the build output a little bit more comprehensible , we first change the project name in the generated pom.xml file.
...
Adding version of cxf to pom.xml
We must specify the version of CXF .to use:
No Format |
---|
<project> ... <properties> ... <cxf-version> 2.0.7</cxf-version> ... </properties> ... </project> |
Adding the org.apache.cxf plugin
We add this plugin to the generated pom.xml file to element plugins.
No Format |
---|
<plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf-version}</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <sourceRoot>${basedir}/target/jaxws</sourceRoot> <wsdlOptions> <wsdlOption> <wsdl>${basedir}/src/main/resources/service.wsdl</wsdl> <extraargs> <extraarg>-verbose</extraarg> </extraargs> </wsdlOption> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin> |
This plugin is use used for generating java classes from the WSDL file. We use the wsdl2java tool from JAX-WS (CXF framework).
Where service.wsdl is The next step is to copy the WSDL file , which we already made in the my-cxf-bc-su to the my-cxf-se-su . We must copy this WSDL file from because we need it to generate
the java classes from it. So copy it now:
- from folder: my-cxf-bc-su/src/main/resources
- to
...
- folder: my-cxf-se-su/src/main/resources
After doing this, we need to run mvn install in order to get the java classes generated.
Implementing generated ExampleService.java
We must implement our service in java. In our example, it's HelloImpl.java
Code Block | ||||
---|---|---|---|---|
|
...
| |||||
package org.apache.servicemix.examples; import javax.jws.WebService; import javax.xml.ws.Holder; import org.apache.servicemix.examples.types.SayHello; import org.apache.servicemix.examples.types.SayHelloResponse; @WebService(serviceName = "HelloService", targetNamespace = "http://servicemix.apache.org/examples", endpointInterface = "org.apache.servicemix.examples.Hello") public class HelloImpl implements Hello { public void sayHello(Holder<String> name) throws UnknownWordFault { if (name.value == null || name.value.length() == 0) { org.apache.servicemix.examples.types.UnknownWordFault fault = new org.apache.servicemix.examples.types.UnknownWordFault(); throw new UnknownWordFault(null, fault); } name.value = "Hi " + name.value; } } |
Configuring xbean.xml
Next , we will have to configure our new SU to really provide some serviceswebservice. We do this by modifying the file
named xbean.xml in the src/main/resources directory of our my-cxf-se-su module.:
No Format |
---|
<cxfse:endpoint> <cxfse:pojo> <bean class="org.apache.servicemix.examples.HelloImpl" /> </cxfse:pojo> </cxfse:endpoint> |
...
- You specify the plugin for a SU in Maven's pom.xml file
- In ServiceMix, most service units will be configured by a file named xbean.xml
Proceed to the next step
Wiki Markup |
---|
{scrollbar} |