Developing a simple SOAP-webservice using Spring 3.0.1 and Apache CXF 2.2.6
In the past few years many techniques have been developed to help applications interact with each other. One of them are webservice-interfaces. These interfaces are extremly popular in the world of Java software development. One Framework that can be used to build such interfaces is Apache CXF. Apache CXF delivers a toolset to develop interfaces using different protocols like XML/HTTP, RESTful HTTP, Corba and SOAP. In this article i'd like to show how easy it could be to develop a simple SOAP-webservice based on Apache CXF 2.2.6 and the Spring Framework 3.0.1. You can download the full example at the bottom of this article.
Setting up the project...
First I set up a small Maven 2 project that packages my application as a web application archive (*.war-file). Therefore I created the following pom.xml:
- <project xmlns="...">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.unitedcoders.demo</groupId>
- <artifactId>CXFExampleService</artifactId>
- <packaging>war</packaging>
- <version>0.0.1-SNAPSHOT</version>
- <name>Example Apache CXF Webservice</name>
- <url>http://united-coders.com</url>
- <!-- Dependency properties -->
- <properties>
- <junit-version>4.5</junit-version>
- <cxf.version>2.2.6</cxf.version>
- <spring-version>3.0.1.RELEASE</spring-version>
- <commons-logging-version>1.1.1</commons-logging-version>
- </properties>
- <!-- Plugin configuration -->
- <build>
- <finalName>CXFExampleService</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-java2ws-plugin</artifactId>
- <version>${cxf.version}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-simple</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>process-classes</id>
- <phase>process-classes</phase>
- <configuration>
- <className>com.unitedcoders.demo.PersonService</className>
- <genWsdl>true</genWsdl>
- <verbose>true</verbose>
- </configuration>
- <goals>
- <goal>java2ws</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <!-- Dependency definitions -->
- <dependencies>
- <!-- Apache CXF dependencies -->
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <!-- Spring Dependencies -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>${spring-version}</version>
- </dependency>
- <!-- Logging -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>${commons-logging-version}</version>
- </dependency>
- <!-- Testing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit-version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </project>
My projects structure
- phil@invader:~/Projects/CXFExample$ tree
- .
- |-- README.txt
- |-- pom.xml
- `-- src
- |-- main
- | |-- java
- | | `-- com
- | | `-- unitedcoders
- | | `-- demo
- | | |-- Person.java
- | | |-- PersonService.java
- | | `-- PersonServiceImpl.java
- | |-- resources
- | | `-- application-context.xml
- | `-- webapp
- | `-- WEB-INF
- | `-- web.xml
- `-- test
- `-- java
- `-- com
- `-- unitedcoders
- `-- demo
- |-- PersonServiceImplTest.java
- `-- PersonTest.java
- 14 directories, 9 files
- phil@invader:~/Projects/CXFExample$
Let's first take a look on what has happened here. I defined some Apache CXF 2.2.6 dependencies which are needed to create my SOAP-webservice. To use the Spring framework in my little project I also added spring-core and spring-web in version 3.0.1 to my dependencies. Additionally I defined some other dependencies like JUnit and Apache commons-logging. But what has happend to the Maven 2 plugins? The first plugin I configured in my project is the maven-compiler-plugin. This plugin is a plugin of Mavens standard lifecycle. My configuration lets Maven 2 know which Java version should be used to compile my source. I prefer to use Java 1.6. The second plugin I defined is the cxf-java2ws-plugin. This Maven 2 plugin helps me to generate a WSDL-file from my annotated Java webservice-class.
Developing the SOAP webservice
To have a little showcase I created a simple class "Person" containing the only one member field "name". Later on the webservice should get a persons name from a client and answer with a short greeting like „Hello [NAME]!“.
- package com.unitedcoders.demo;
- public class Person {
- private String name;
- public Person(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- }
- package com.unitedcoders.demo;
- import javax.jws.WebService;
- @WebService
- public interface PersonService {
- public String greetPerson(String name);
- }
- package com.unitedcoders.demo;
- import javax.jws.WebService;
- @WebService(endpointInterface = "com.unitedcoders.demo.PersonService")
- public class PersonServiceImpl implements PersonService {
- public String greetPerson(String name) {
- Person person = new Person(name);
- return "Hello " + person.getName() + "!";
- }
- }
Combining everything
To get the webservice working I finally combined Spring and my webservice-implementation. Therefore I first defined the applications context. First I added three imports to my applications context. There are three imports that add CXF-specific bean definitions and configurations to my applications context. After that a singleton bean of my webservice is needed. And at least a jaxws:endpoint is defined that maps my bean to the endpoint to the path "/personService".
application-context.xml:
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="..."
- xsi:schemaLocation="...">
- <import resource="classpath:META-INF/cxf/cxf.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
- <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
- <!-- Spring manage ServiceBean -->
- <bean id="personServ" class="com.unitedcoders.demo.PersonServiceImpl" />
- <!-- JAX-WS Service Endpoint -->
- <jaxws:endpoint id="personService" implementor="#personServ" address="/personService" />
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="...">
- <display-name>CXF Example Webservice</display-name>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:application-context.xml</param-value>
- </context-param>
- <servlet>
- <servlet-name>CXFServlet</servlet-name>
- <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>CXFServlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
- </web-app>
Testing the new SOAP-webservice
After building this Maven 2 project with „mvn clean package“ a new war-file will be placed in the target folder. This war-file now contains an entire webservice. If it is deployed on a Java web container like Apache Tomcat you can reach the webservice by accessing it in your browser.
http://[YOUR TOMCAT]:[PORT]/CXFExampleService/personService?wsdl
To run some functional tests on the new webservice an test if the webservice works as expected I used soapUI which can be downloaded here. soapUI is a really famous tool that can be used to test webservices. It can be used as a standalone application or as a IDE plugin (e.g. for eclipse).
Download the full example:
Some resources:
http://cxf.apache.org
http://www.springsource.org/download
http://www.soapui.org
Attachment | Size |
---|---|
united-coders.com-CXFExample.tar_.bz2 | 2.53 KB |
united-coders.com-CXFExample.zip | 8.26 KB |
- Login to post comments
Comments
Anonymous (not verified) - Mon, 03/01/2010 - 10:48
Thanks for your guide!
Anonymous (not verified) - Tue, 04/12/2011 - 09:28
I have used your example to run my application by changing the parameters. I am getting the following error. Can anyone help me out?
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [application-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [application-context.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:829)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:718)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.io.FileNotFoundException: class path resource [application-context.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 36 more
Anonymous (not verified) - Tue, 04/12/2011 - 11:47
you sure this file is present?
Anonymous (not verified) - Tue, 04/12/2011 - 11:54
Applicationcontect.xml is available under the src/main/resources folder. Do I need to change the location of this ?
Nico Heid - Tue, 04/12/2011 - 18:38
this is not the same as application-context.xml
change the file name.
Anonymous (not verified) - Wed, 04/13/2011 - 19:25
same file only. Mistake in mailing
Alisia Tweed (not verified) - Thu, 05/05/2011 - 07:07
I was looking out for information on this since quiet a long time now. I consider you’ve created some genuinely exciting points. It helps me very much to solve some problems. Its opportunity is so fantastic and working style so speedy. I think it may be help all of you. It could be a great tool in many ways for research. I will definitely use it in my work.. I have enjoyed reading, Thank you for your info, greatly appreciated.
Philadelphia Web Design
Anonymous (not verified) - Thu, 03/04/2010 - 00:40
good work, I appreciate it! detailed clean and easy to understand!
Andrew (not verified) - Tue, 03/09/2010 - 16:35
Can you give us a little more insight into the cxf files referenced within the application-context.xml?
I don't see those files in your tar file. What a they for and are they needed?
Phillip Steffensen - Wed, 07/14/2010 - 20:45
The cxf files referenced in application-context.xml are delivered by the cxf dependencies.
You can take a closer look on them if you browse into these dependencies.
Christian Harms - Wed, 04/28/2010 - 07:34
Found a deployment-question on stackoverflow: http://stackoverflow.com/questions/2635660/apache-cxf-cxf-java2ws-plugin...
Anonymous (not verified) - Wed, 05/05/2010 - 18:06
Excellent work, just what I was looking for!-)
Anonymous (not verified) - Wed, 06/23/2010 - 15:02
hi,
Thanks you for your example. But i 'd like to ask you in which directory is generated the wsdl using the plugin cxf-java2ws-plugin.
Vincent (not verified) - Tue, 07/20/2010 - 08:39
Hi,
Excellent Job you did, it is very very useful to me.
Thanks,
Vincent
Rajesh Kollam (not verified) - Wed, 07/28/2010 - 08:11
Ecellent example. This is really helped me.
Vlad (not verified) - Tue, 08/31/2010 - 00:25
Excellent example, would be nice if wsdl had Person::name like in java rather than Person::arg0.
Also it offers manual testing using SOAP UI rather than having honest http junit test.
Vlad (not verified) - Tue, 08/31/2010 - 00:55
Here is the fix to make wsdl look better (person should have "name" attribute instead of "arg0"):
public String greetPerson(@WebParam(name = "name") String name);
Brian (not verified) - Sat, 09/25/2010 - 18:23
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.resource.ResourceManager' defined in class path resource [META-INF/cxf/cxf.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.unitedcoders.demo.PersonServiceImpl] for bean with name 'personServ' defined in class path resource [application-context.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.unitedcoders.demo.PersonServiceImpl)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.unitedcoders.demo.PersonServiceImpl] for bean with name 'personServ' defined in class path resource [application-context.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.unitedcoders.demo.PersonServiceImpl)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:570)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:382)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:376)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1109)
at org.apache.cxf.bus.spring.Jsr250BeanPostProcessor.postProcessAfterInitialization(Jsr250BeanPostProcessor.java:76)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:404)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
... 35 more
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.unitedcoders.demo.PersonServiceImpl)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2737)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1229)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1200)
... 45 more
Sep 25, 2010 12:46:40 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Sep 25, 2010 12:46:40 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Sep 25, 2010 12:46:40 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Brian (not verified) - Sun, 09/26/2010 - 15:16
I found my problem, I was running tomcat under the wrong version of Java.
brian
Anonymous (not verified) - Wed, 10/20/2010 - 06:40
hey i am new to this soap spring webservices
can some one pls tell how can i use this "personService" as end point from my client application?
Thank you.
Jason (not verified) - Wed, 11/03/2010 - 02:59
I've been looking all over for examples on how to quickly get a webservice running under Spring 3.0. It's difficult to find any JAX-WS examples. I tried the jax-ws-commons extension and could not get it to work. After spending most of my day trying to get something to work, I had Apache CXF up and running in about an hour. Your example made it a piece of cake. Thanks a lot for putting up this page!
Anonymous (not verified) - Fri, 11/19/2010 - 09:46
Finally something that worked! And so simple. I too tried to get Spring JAX-WS working first but it was overcompilacted disaster. Plus this works on a mere servlet containers, no need to involve Glassfish. @WebParam was a good hint too.
Anonymous (not verified) - Fri, 11/19/2010 - 13:10
I generated some web service tests using soapUI and added them to maven build. Details are found at http://www.soapui.org/Test-Automation/maven-2x.html. However all of the pom.xml tags on that page are missing since somebody added xml straight into html... However you can see the tags using browsers view source.
Here is quick start.. First use soapui to generate test from WSDL then save the project to maven project tree under src/test/soapui/.
Then add soapui plugin stuff to pom.xml.
1. Add eviware maven repo:
2. Add soapui plugin to plugins section:
3. Run tests with
mvn eviware:maven-soapui-plugin:test
I first tried to add web service test execution to maven test phase, but that didn't work out too well since application was not yet deployed and jetty was not yet running :p
Anonymous (not verified) - Wed, 12/22/2010 - 20:58
I am getting this error when I am trying to run the sample application in Jetty.
Problem accessing /personService. Reason:
Caused by:
rakesh kumar (not verified) - Tue, 03/08/2011 - 08:19
org.apache.cxf.interceptor.Fault: Response was of unexpected text/html ContentType. Incoming portion of HTML stream:
WSDL : {http://demo.unitedcoders.com/}PersonServiceImplService
Target namespace: http://demo.unitedcoders.com/
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:79)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:733)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2201)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2071)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1925)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:662)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
at $Proxy31.greetPerson(Unknown Source)
at com.unitedcoders.demo.TestClient.main(TestClient.java:15)
Exception in!doctype>
Prasanna (not verified) - Sun, 03/20/2011 - 02:39
Thank you so much.. i struggled for almost a day.. but couldn't get it right.. but your tutorial.. got the juices flowing in under 30 mins.
it is working (not verified) - Thu, 04/21/2011 - 16:54
I was thinking this was impossible me to make, but finally found this tutorial and understood it in a minutes.
Thank you very much!
Anonymous (not verified) - Fri, 07/29/2011 - 13:38
Caused By: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
Truncated. see log file for complete stacktrace
sfeher (not verified) - Thu, 08/11/2011 - 06:02
It might be filtered out by maven war plugin and/or file name has mixed case.
Anonymous (not verified) - Tue, 09/27/2011 - 11:19
Tried using winzip to unpack and view these files - no luck. Spent too much time... moving on.
Anonymous (not verified) - Tue, 09/27/2011 - 12:33
if you use winzip 11 or higher it will work. or use 7zip.
but you don't want to tell me that you do not know the file extension bz2 or could at least google it?
Anonymous (not verified) - Thu, 09/29/2011 - 01:17
My Winzip 14.5 unzipped the bz2 into a tar file, but from there, I could find nothing about turning it into something useful in Windows 7. Yes, I googled the $&*# out of it, and spent too much time on it, but thanks for trying to help me out.
Nico Heid - Thu, 09/29/2011 - 08:15
hey, i repackaged it into a zip for you (see attachements): http://united-coders.com/sites/default/files/united-coders.com-CXFExampl...
you'd either need 7zip as mentioned, or if you end up wit a tar and don't want 7zip, you could use tar for windows.
but now you can just use the zip file.
hope we could help
yerico (not verified) - Thu, 10/27/2011 - 14:35
Use Total Commander! Select the .bz2 file, press CTRL + PAGE DOWN. You will get the .tar file. Repeat the pressing of the CTRL + PAGE DOWN and you will see the source you need. Simple copy it to the location you want.
Evgeny Sirikh (not verified) - Thu, 10/27/2011 - 15:57
lol, you such a funny guys. sure no cfx-...xml in this archive. No archiver will help find files which not exist in archive :)
Those files located in cxf-2.x.x.jar. Make sure you have it in class path.
Regards.
Addy (not verified) - Fri, 10/07/2011 - 03:25
Hi,
I am new to Soap-web service using Spring3.x and Apache CXF2.x
plus i have a security restriction on my workstation that i can not go online to get the dependencies using maven. Can you please help me how can i develop spring web service, generate the wsdl file and test it with soapUI after deploying it on IBM Websphere 7 without involving maven.
i will be really thankful.
Addy
QWEB (not verified) - Thu, 10/20/2011 - 06:19
Hi,
Very good article on CXF with Spring. Clean explanation.
It was really helpful
Thanks,
QWEB
deviprasad (not verified) - Fri, 10/21/2011 - 04:05
Hai...
This is deviprasad Raju, i'm new to this SOAPUI and i got stucked with the debugging of my web application using xml's. i was able debug my application but when i run run request xml by passing some inputs in the response xml i'm getting error name "error in creating instance of the class" what it actually means... can you please tell how to get out from this.............
yerico (not verified) - Thu, 10/27/2011 - 14:31
Great job, it was very helpful for me. Thanks!
sam (not verified) - Sat, 10/29/2011 - 16:04
can u pl provide ant version of the same webservice
top (not verified) - Wed, 11/02/2011 - 06:16
i am using spring MVC , i have dispatcher-servlet.xml file , so i can't write on that file because i am doing mapping in controllers (using @Controller
@RequestMapping("/home") ). in this case how can i do the mapping part for above web services ?
thanks
kiran (not verified) - Sat, 11/05/2011 - 00:54
Phillip,
Thank you very much for an excellent tutorial.
I have this question.
while testing the service we give the url as
http://localhost:8080/CXFExampleService/personService
in the SoapUI.
My question is how and where the string "personService" is mapped to the service name in the wsdl ?
-Kiran
kiran (not verified) - Sat, 11/05/2011 - 01:20
Phillip,
I was able to figure the answer to my question. The Application-cotext.xml explains very well to my question.
Thanks any way.
Anonymous (not verified) - Tue, 11/29/2011 - 05:55
Hi
Its very good article .. . Now i have one doubt that ,how we can I create a client application (J2EE application ) to communicate with this server web services.
Please give me any suggestion
Anonymous (not verified) - Mon, 12/05/2011 - 07:28
Hi,.
I just found error in application-context file: " Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://cxf.apache.org/schemas/jaxws.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jaxws:endpoint'."
Please help me fix this one.
Thanks so much.
Sumit Bansa;l (not verified) - Thu, 12/08/2011 - 08:03
Hi, many thanks for this simple & crisp example, it was really helpful.
Regards,
sSumit Bansal
Alok Chandra (not verified) - Mon, 12/12/2011 - 10:50
Hi,
Many thanks for this examples. But use the following version of spring while running this example
3.0.2.RELEASE .
Other wise it will give the following exception
java.lang.ClassNotFoundException: org.springframework.core.convert.support.PropertyTypeDescriptor
Arun Jolly (not verified) - Mon, 12/19/2011 - 16:20
Awesome...I just changed the source and target to 1.5 ( cos i wanted it that way ) in the pom, built it, deployed and tested it...All in 5 minutes !!...Awesome Post Man !!...Thanks !!
KP (not verified) - Tue, 12/27/2011 - 13:34
Excellent Tutorial, Easy and effective. Thanks for sharing.
KP (not verified) - Tue, 12/27/2011 - 13:34
Excellent Tutorial, Easy and effective. Thanks for sharing.