You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

On this page, we are going to configure the my-cxf-se-su to provide our service .

Configuring 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.

 
<project>
  ...
  <name>CXF WSDL Tutorial :: CXF SE SU</name>
  ...
</project>

Adding parent's element to generated pom.xml

We must to specify parent of this project. So, we add this to generated pom.xml.

 
 <parent>
    <artifactId>parent</artifactId>
    <groupId>org.apache.servicemix.tutorial</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

Adding version of cxf to pom.xml

We must specify version of CXF.

 
<project>
...
  <properties>
    ...
	<cxf-version> 2.0.7</cxf-version>
    ...
  </properties>
...
</project>

Implementing generated ExampleService.java

We must implement our service in java. In our example, it's HelloImpl.java

package com.mycompany.hello;

import javax.jws.WebService;
import javax.xml.ws.Holder;

import com.mycompany.hello.types.SayHello;
import com.mycompany.hello.types.SayHelloResponse;

@WebService(serviceName = "HelloService", targetNamespace = "http://mycompany.com/hello", endpointInterface = "com.mycompany.hello.Hello")
public class HelloImpl implements Hello {

    public void sayHello(Holder<String> name)
        throws UnknownWordFault
    {
        if (name.value == null || name.value.length() == 0) {
            com.mycompany.hello.types.UnknownWordFault fault = new com.mycompany.hello.types.UnknownWordFault();
            throw new UnknownWordFault(null, fault);
        }
 
      name.value = "Hi " + name.value;
    }

}

Adding org.apache.cxf plugin

We add this plugin to the generated pom.xml file to element plugins.

<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>

Where service.wsdl is WSDL file, which we made in my-cxf-bc-su. We must copy this WSDL file from my-cxf-bc-su/src/main/resources to
my-cxf-se-su/src/main/resources.

Next, we are going to create our second SU.

Things to remember

  • 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



  • No labels