Web Services Tutorial with Apache CXF
I created a web service today with CXF and wanted to share the steps it took to get it up and running in this quick tutorial. Apache CXF was created by the merger of the Celtix and XFire projects. I chose to implement my service in CXF because some colleagues had been using XFire and would likely want to upgrade at some point. I am using the latest version, which is 2.0.4. While the library itself seems to be of high quality, the documentation is still a work in progress. However, do not fret because this CXF tutorial will get you up and running in no time. I will be creating a simple web service that will allow the retrieval of employee information. The service will return this simple POJO (Plain Old Java Object) bean with matching getters and setters:
package com.company.auth.bean;
import java.io.Serializable;
import java.util.Set;
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private String gid;
private String lastName;
private String firstName;
private Set<String> privileges;
public Employee() {}
public Set<String> getPrivileges() {
return privileges;
}
public void setPrivileges(Set<String> privileges) {
this.privileges = privileges;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getGid() {
return gid;
}
public void setGid(String gid) {
this.gid = gid;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public boolean isUserInRole(String role) {
if(privileges == null) { return false; }
else { return privileges.contains(role); }
}
}
First off, you need to download Apache CXF and drop the necessary .jars in your WEB-INF/lib directory:
aopalliance-1.0.jar
commons-logging-1.1.jar
cxf-2.0-incubator.jar
geronimo-activation_1.1_spec-1.0-M1.jar (or Sun’s Activation jar)
geronimo-annotation_1.0_spec-1.1.jar (JSR 250)
geronimo-javamail_1.4_spec-1.0-M1.jar (or Sun’s JavaMail jar)
geronimo-servlet_2.5_spec-1.1-M1.jar (or Sun’s Servlet jar)
geronimo-ws-metadata_2.0_spec-1.1.1.jar (JSR 181)
jaxb-api-2.0.jar
jaxb-impl-2.0.5.jar
jaxws-api-2.0.jar
jetty-6.1.5.jar
jetty-util-6.1.5.jar
neethi-2.0.jar
saaj-api-1.3.jar
saaj-impl-1.3.jar
spring-core-2.0.4.jar
spring-beans-2.0.4.jar
spring-context-2.0.4.jar
spring-web-2.0.4.jar
stax-api-1.0.1.jar
wsdl4j-1.6.1.jar
wstx-asl-3.2.1.jar
XmlSchema-1.2.jar
xml-resolver-1.2.jar
The first thing which needed to be done was to create the service interface. The service interface defines which methods the web service client will be able to call. It’s pretty standard Java with just two JWS (Java Web Service) annotations thrown in:
package com.company.auth.service;
import javax.jws.WebService;
import javax.jws.WebParam;
import com.company.auth.bean.Employee;
@WebService
public interface AuthService {
Employee getEmployee(@WebParam(name="gid") String gid);
}
The @WebParam annotation is in fact optional, but highly recommended since it will make like easier for the end consumers of your service. Without it, your parameter would be named arg0 making it less clear what parameters your service actually takes.
Implementing the actual service comes next:
package com.company.auth.service;
import javax.jws.WebService;
import com.company.auth.bean.Employee;
import com.company.auth.dao.EmployeeDAO;
@WebService(endpointInterface = "com.company.auth.service.AuthService", serviceName = "corporateAuthService")
public class AuthServiceImpl implements AuthService {
public Employee getEmployee(String gid) {
EmployeeDAO dao = new EmployeeDAO();
return dao.getEmployee(gid);
}
}
I then had to tell Spring (which is used by CXF) where to find my Java classes. I created the following cxf.xml file inside my package directory (com/company/auth/service):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<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" />
<jaxws:endpoint id="auth"
implementor="com.company.auth.service.AuthServiceImpl"
address="/cxfAuth"/>
</beans>
Finally, I updated my WEB-INF/web.xml file to let CXF know where my cxf.xml file was and define the CXF servlet:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Auth Manager</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:com/company/auth/service/cxf.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
The most frustrating portion of getting the CXF web service up and running was the following exception:
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.jws.WebService.portName()Ljava/lang/String;
This is due to the fact that I am running WebLogic 9.2, which contains a library with an older version of JSR (Java Specification Request) 181. The quickest solution for me was to prepend geronimo-ws-metadata_2.0_spec-1.1.1.jar to the WebLogic classpath. This will likely not be the solution I choose to implement in the end, but it got me back up and running. It seemed I also had to clear my WebLogic cache for this fix to take effect. Because I often find instances where this seems necessary, I have created a Windows script to clear the Weblogic Cache. If you run into app server related issues, this was one area I found the Apache CXF docs to be helpful.
Also, if you are running Hibernate, you may encounter ASM incompatibilities between Hibernate’s CGLib and the version of ASM which CXF requires. But do not fret because this is easy enough to solve.
Once this was solved, the list of services was available. The context root for my web project is authManager, so my regular web index page is available at http://localhost:7001/authManager/. The list of web services is then automagically generated by CXF at http://localhost:7001/authManager/services/.
The final step is to build the client. This was very easy when compared to getting the server up and running because I was able to simply swipe the code from the Apache CXF documentation. So, without further ado:
package com.company.auth.client;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.company.auth.bean.Employee;
import com.company.auth.service.AuthService;
public final class Client {
private Client() {
}
public static void main(String args[]) throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(AuthService.class);
factory.setAddress("http://localhost:7001/authManager/services/cxfAuth");
AuthService client = (AuthService) factory.create();
Employee employee = client.getEmployee("0223938");
System.out.println("Server said: " + employee.getLastName() + ", " + employee.getFirstName());
System.exit(0);
}
}
Wow! Wasn’t that cool? (Yes, I’m a dork
) You should now be up and running with a CXF web service.
If you are looking for something to learn next then may I suggest our tutorial on adding security to your web service. That tutorial will also show you how to setup the client using Spring, which you may find helpful as well.
Tags: CXF, SOA, Tutorial, Web Services, WebLogic

Espen Schulstad said,
February 5, 2008 at 2:37 am
Thx, great article. Got the juices flowing in the cxf-grinder in no time
Ben said,
February 5, 2008 at 8:32 am
Thank you Espen. I’m so happy to hear the CXF tutorial was helpful. As a new blogger, I’m always open to suggestions, so feel free to let me know if there was anything that wasn’t clear enough.
-Ben
Alessandro said,
February 12, 2008 at 4:00 pm
Hi Ben
Even if I’m a newbie at webservices I found your tutorial very useful, thanks.
Anyway I have a doubt: everything works just fine if I had a method returning, for example a String. If I try to make it returning an Object (for example an Employee) I get a message about the marshalling process of my bean (Employee).
Any advice?
Thanks, Alessandro
Ben said,
February 12, 2008 at 6:07 pm
Alessandro,
Glad to hear you’re part way there!
It sounds to me like you’ve encountered a problem serializing your Object to XML. CXF and other web services take your object, turn it into XML, and then transmit it over HTTP as XML. Since it is having trouble turning your Object into XML, there is probably some object member that is not a simple data type or composed of them. You can return your custom Objects composed of standard Java classes as you can see from my example bean above. If your class has something like say a File or BufferedImage in it then it’s a lot less likely that JAXB will know how to turn that into XML. I’d comment out anything that’s not a standard data element and see if it works. Adding them back in one at a time, you should be able to see which cause you problems. If that’s what’s wrong then a good place to start in the documentation would be http://cwiki.apache.org/CXF20DOC/databindings.html If you’re really unable to turn your objects into XML, then CXF can handle other bindings like CORBA, but I’m not sure that any of that is out of the box yet. I think JAXB and Aegis are the two supported right now with XMLBeans, Castor, and JiBX to come in CXF 2.1. There’s some integration with Yoko I believe, but that’s not an area I’d be able to help with.
Alessandro said,
February 13, 2008 at 6:16 am
Ben,
thanks for your very quick reply.
Yes, my problem is that CXF can’t serialize my class to XML, and the error I get is
‘org.apache.cxf.interceptor.Fault: Marshalling Error: SdrProcess is not known to this context’.
I’m tryin’ to make CXF marshalling automatically by putting annotation in my class, like follows:
I’m expecting CXF to do the marshalling by itself, am I right or am I missing some configuration?
I’m not putting the class full qualified name (w/package). is it maybe that?
I’m not sure about the link you posted about the wiki: it doesn’t work, are you sure it is that?
Thanks a lot!
Alessandro
dom said,
February 14, 2008 at 10:58 am
is it possible to post the source up here?
Ben said,
February 14, 2008 at 2:58 pm
Dom,
Which source specifically do you want to see? Basically all of the source code is already in the post.
Ben said,
February 14, 2008 at 3:53 pm
Alessandro,
You DO need the fully qualified class name of your service implementation in the cxf.xml Spring configuration file. You also, DO need the fully qualified class name of your service interface when specifying the endpoint interface in your service implementation.
You don’t need any annotations in your bean for CXF. It will work correctly with just a POJO (Plain Old Java Object). However, I don’t think CXF will like having only getters. If I remember correctly, you need to have matching getters and setters.
Also, I corrected the link in my previous comment.
-Ben
dom said,
February 15, 2008 at 9:48 am
Hi ben , just the employees stuff, i am getting an error saying : org.apache.xbean.propertyeditor.PropertyEditorException: Value is not an instance of Map
thanks for spending the time to write all of this.
Dom
Ben said,
February 15, 2008 at 2:13 pm
Dom,
I added the code for my bean to the post. As I stated, it really is just a simple POJO.
I’m not sure where you are getting the error you mentioned, but I’d make sure whatever method you call in the stack trace that is expecting a Map is actually being passed a class which implements the Map interface such as a HashMap.
-Ben
dom said,
February 18, 2008 at 4:32 am
Would you be able to post your DAO up as well? Sorry i am very new to this and i am just trying to get a working example. My lastest error that i am getting is : Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents. Any thoughts would be geat
dom said,
February 18, 2008 at 5:35 am
here what i have done for my DAO.
Ben said,
February 19, 2008 at 11:10 am
Hi Dom,
I’ve edited a few lines in your comment to fix some null pointer exceptions that would occur if your code was run so as not to confuse other people that might see it. You might want to update your DAO using the corrections.
-Ben
Apache CXF Tutorial - WS-Security with Spring | Lumidant said,
February 19, 2008 at 5:17 pm
[...] cover adding an authentication component to your web service though WS-Security. If you need an overview of how to setup CXF then you may find our previous tutorial helpful. Another helpful resource is CXF’s own [...]
Digger said,
February 20, 2008 at 12:51 am
I’m getting exactly the same thing as Alessandro regarding marshalling. The root cause is
Caused by: javax.xml.bind.JAXBException: com.xyz.SimpleComment is not known to this context
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:538)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:82)
… 37 more
I get it when trying to return a List of complex types (in this case, a List of SimpleComments). If I return a List of Strings then there’s no problem. I tried Ben’s suggestion above regarding removing properties from the SimpleComment–in fact I removed everything except a single String property–but no luck. Just curious whether other people are running into this when trying to return a complex type.
Ben said,
February 20, 2008 at 3:44 pm
I would think your best bet is to look into other data bindings as I mentioned earlier. I tried to get Aegis working today, but didn’t have any luck. I’ll try a bit more and update you if I get it working. In the meantime, would you be able to use a Set instead of a List? A Set worked for me using JAXB and unless the ordering matters to you that might be a quick fix.
Sadashiv said,
February 20, 2008 at 4:01 pm
Hi Ben,
Thanks for the good tutorial. I wanted to know how can we do logging of soap request and response using CXF. using configuration files. I used following url ( http://cwiki.apache.org/CXF20DOC/configuration.html ) to do it through configuration but it gives me following exception. Please let me know what iam doing wrong
INFO: Load the bus with application context
20 Feb 2008 20:27:19,653 ERROR [[/MyCXFWebservice],] StandardWrapper.Throwable
java.lang.NullPointerException
at org.apache.cxf.transport.servlet.CXFServlet.loadSpringBus(CXFServlet.java:104)
at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:63)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.init(AbstractCXFServlet.java:86)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Ben said,
February 20, 2008 at 4:55 pm
I found someone else on the mailing list getting your same error. Here was his fix: “I just tried copying the xml files I’m importing in spring.xml into my WEB-INF/classes directory. This fixed the NullPointerException (not sure why it couldn’t find them with the default imports on the classpath).” So I’d check if you’re having a classpath issue.
If you’d like another example, you can see that I added logging in a similar manner in my Spring WS-Security post: http://www.lumidant.com/blog/apache-cxf-tutorial-ws-security-with-spring/
Digger said,
February 20, 2008 at 5:38 pm
Thanks Ben for the suggestions. I will give the Set and Aegis ideas a try and see what happens. If I have any luck I’ll report back.
Sadashiv said,
February 20, 2008 at 7:01 pm
Hi Ben,
Thanks for your response i used ur example and it worked fine but i cannot see the <soap> message in the log file do i need to add anything in order to view ?
thanks in advance
Sada
Digger said,
February 20, 2008 at 11:56 pm
Ben–your suggestion to use Aegis worked great. Thanks dude.
Digger said,
February 21, 2008 at 12:00 am
p.s. You mentioned that you didn’t get Aegis working. Let me know if you need help with that. Here’s what I put in my Spring config:
Rama said,
February 27, 2008 at 8:47 am
Great Blog!! Hope you come out with more such example based articles.
I had a question on Interceptors. I wrote my custom outboundInterceptor. I am trying to get the soap envelope message and log it to a custom logger.
But all my attempts have failed. Turning to you for some help.
Ben said,
February 27, 2008 at 11:29 am
Hi Rama,
I’m afraid I have not created any custom interceptors yet. However, setting up the logging interceptors provided with CXF is relatively easy and might be worth a look. There’s an example of it in the tutorial on this blog which covers CXF with Spring enabled WS-Security.
-Ben
Rama said,
February 28, 2008 at 9:37 am
Thanks for your response. I did some research and found a way to do it. Actually the Nabble forum on CXF is a wonderful resource. The reason my buffer was empty was because i accessed the buffer before the caching from outputstream could complete. So I had to write a LoggerCallback as illustrated in the Nabble forum. So here is what I did..
Ben said,
February 28, 2008 at 9:47 am
Thanks for your example Rama! Also, I’ll second the Nabble forums being a great resource for CXF. Some of the developers hang out there and have been quite helpful.
Ben said,
February 29, 2008 at 4:39 pm
I mentioned Aegis to a few people and it sounds like it’s been pretty promising, so I may update the tutorial soon with some Aegis tips. There’s an Aegis bug that’s stopping me from getting it up and running in my environment. However, Dan Kulp and Benson Margulies have been absolutely great in helping me out and I’m expecting a fix at some point. Regarding the test case I sent him, Dan says:
Brian said,
March 7, 2008 at 1:39 pm
When developing a web service this way, does it not create a wsdl file? I’ve tried starting with a class and running java2wsdl but no luck, I keep getting the following exception : org.apache.xerces.dom.DocumentImpl.getInputEncoding()Ljava./lang/String; I need to have a wsdl because that is what we will publish to our clients. Any idea what is going on?
Ben said,
March 10, 2008 at 12:17 am
Yes, CXF does generate a wsdl. You do not need to run java2wsdl. Simply visit your equivalent of http://localhost:7001/authManager/services/
mansour said,
March 27, 2008 at 4:38 pm
I am working on a project to call web services from VBScript code of an Outlook form. Do you have any suggestions for useful links or any samples?
thanks
Mansour
mansour said,
March 27, 2008 at 4:44 pm
(I sent the following after I read your article above but I sent it to a different thread by mistake. So here I copy that)
Thanks. It was very helpful. I had been reading about CXF for the past four or five hours when I found your article. Things came together after that. It was clear and easy to understand. Being a professional requires you to be able to transfer your knowledge efficiently and in a simple way. And it shows you are one.
Mansour
Andy said,
April 10, 2008 at 9:48 pm
Thanks for the great blog.
I am hoping someone reading this will be able to help me.
I am returning a List from my webservice. The response (sans the headers) look like this:
…SomeObject1
…SomeObject2
without a root element. How do I add a root element to my response?
Any help appreciated.
Ron Holckener said,
May 1, 2008 at 12:02 am
Hi,
I am trying to use CXF (2.0.5) as a web service client, on weblogic 9.2.
I managed to run the client as a standalone, but when I add the relevant CXF jars to the classpath of weblogic I get the below exception, since you managed to deploy can you please assist or state exactly what were your steps in making it work.
Thx
Ron
#### <>
#### <>
#### <>
#### <>
#### <> <[WebAppModule(bea_wls_internal:bea_wls_internal.war)] Error parsing descriptor in Web appplication “D:\csc_75\config\cscjmsdomain\servers\cscjmsserver\tmp\.internal\bea_wls_internal.war”
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:558)
at weblogic.servlet.internal.WebAppReader2.getText(WebAppReader2.java:160)
at weblogic.application.descriptor.BasicMunger2._onDTD(BasicMunger2.java:485)
… more
Baskar said,
June 3, 2008 at 5:12 am
Hi,
I am newbie to Apache-CXF. I need a basic tutorial. Also give me a complete idea of the above code. How to run it and test it.
Thanks in Advance
Ben said,
June 3, 2008 at 1:29 pm
Hi Baskar,
This was meant to be a tutorial for those who had never used CXF before, so let me know if there is a particular portion that is not clear. Do you have much experience with Java in general?
As far as running and testing the code is concerned, to run the server-side portion you should create a web project, deploy it to your server, and then start the server. The server-side portion will start up along with your web application because of the servlet mapping that I showed how to create in your web.xml. You can the run the client by running the main method that I included in the example Client class, which will contact the server to get some data.
Baskar said,
June 4, 2008 at 12:52 am
Hi Ben,
Thanks for your prompt reply. I managed to run it successfully. Will get back to you if i need further help from you. Also send me some good PDF or tutorial to dig into details about Apache CXF.
Thanks in Advance,
Baskar.S
Baskar said,
June 5, 2008 at 8:28 am
Hi Ben,
You have given an example for Java to WSDL. Can you provide an example for WSDL to java?
Thanks,
Baskar.S
Ben said,
June 5, 2008 at 8:49 am
Hi Baskar,
I’d recommend you check out the CXF wiki docs.
-Ben
Diego Ardila said,
June 6, 2008 at 10:16 am
Hi,
I am newbie to Apache-CXF. I am trying to use it but I have encountered some problems with the binding. Each time I try to send a message, I obtain the following exception:
org.apache.cxf.interceptor.Fault: Couldn’t instantiate class. constant manager.business.model.dtos.ConstantFilterDTO. Nested exception is java.lang.InstantiationException: constantmanager.business.model.dtos.ConstantFilterDTO
…
Caused by: org.apache.cxf.aegis.DatabindingException: Couldn’t instantiate class
constantmanager.business.model.dtos.ConstantFilterDTO. Nested except
Can you help me?
Thanks in Advance,
Diego A.
PD.
How can I be sure CXF is using Aegis for the binding. Now I am forcing the client with the line:
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
But I am not sure whether the application in the server is correctly configured .
Baskar said,
June 10, 2008 at 8:15 am
Hi,
I deployed this Apaxhe CXF example in Tomcat and ran it successfully. But i would like to deploy the same in JBoss. I am new to JBoss. Can anyone help me to deploy the above Apache CXF example in JBoss and test the same.
Thanks,
Baskar.S
Mandish said,
June 19, 2008 at 6:40 am
Hi people,
I tried to run this tutorial and got exception like:
2008-06-19 16:31:28,687 ERROR [] org.springframework.web.context.ContextLoader – Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘auth’: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/sun/xml/bind/marshaller/NamespacePrefixMapper
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/bind/marshaller/NamespacePrefixMapper
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createDefaultDataBinding(ReflectionServiceFactoryBean.java:173)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.getDataBinding(AbstractServiceFactoryBean.java:56)
at org.apache.cxf.frontend.ServerFactoryBean.applyExtraClass(ServerFactoryBean.java:201)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:104)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:160)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:322)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:244)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:194)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:380)
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)
…
Any idea?
Regards,
Mandish
Ben said,
July 1, 2008 at 1:37 pm
Hi Mandish,
It looks like you’re missing a jar file. I’d guess that class is contained in the JAXB jar or similar.
-Ben
yelena modlovic said,
July 29, 2008 at 1:29 am
I follow your tutorial , it was built successfully and I got the wsdl generated at http://localhost:8080/WebApplication5/services/swAuth?wsdl . but when I tried to run the client program it gave me errors like :
og4j:WARN No appenders could be found for logger (org.apache.cxf.bus.spring.BusApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Jul 29, 2008 1:52:20 PM org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
Jul 29, 2008 1:52:24 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://service.auth.company.com/}AuthServiceService from class com.company.auth.service.AuthService
Jul 29, 2008 1:52:26 PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
—————————
Encoding: UTF-8
Headers: {SOAPAction=[""], Accept=[*]}
Messages:
Payload: 0223938
————————————–
Jul 29, 2008 1:52:26 PM org.apache.cxf.interceptor.LoggingInInterceptor logging
INFO: Inbound Message
—————————-
Encoding: UTF-8
Headers: {Content-Length=[227], X-Powered-By=[Servlet/2.5], Date=[Tue, 29 Jul 2008 08:22:26 GMT], Server=[Sun Java System Application Server 9.1_01], content-type=[text/xml;charset=UTF-8]}
Messages:
Message:
Payload: soap:ServerFault occurred while processing.
————————————–
Exception in thread “main” javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
at $Proxy43.getEmployee(Unknown Source)
at com.company.auth.client.Client.main(Client.java:25)
Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing.
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:65)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:449)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1996)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1832)
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:159)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:591)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
… 2 more
Java Result: 1
BUILD SUCCESSFUL (total time: 11 seconds)
can you enlighten what has happened ?
Ben said,
July 29, 2008 at 8:09 am
Yelena,
There was an exception on the server side (“Payload: soap:ServerFault occurred while processing.”). You should investigate further there. What you posted is the client output, which does help point in the right direction since it tells you to look at the server, but ultimately won’t get you to the final answer
-Ben
rhang said,
August 29, 2008 at 8:38 pm
Yelena
The fault exception you are seeing might be from the buggy EmployeeDAO object that Dom posted. Employee was only declared but never created. Privileges was also only declared but never created. Good work Ben.
eduser said,
October 29, 2008 at 2:10 am
Hi Bhaskar/Ben,
Can you let me know how you run client from eclipse. My service is up and running on server but when I run my Client program as “Run on server” getting bellow error message. I tried to run as “Run as Java application” but no luck.
please let me know how to run client to access employee services.
Error:
Encoding: UTF-8
Headers: {SOAPAction=[""], Accept=[*]}
Messages:
Payload: 0223938
————————————–
Oct 29, 2008 7:42:48 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
at $Proxy43.getEmployee(Unknown Source)
at com.company.auth.client.Client.main(Client.java:25)
Caused by: java.io.IOException: Not Found
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1962)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1865)
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:170)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:593)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
… 7 more
Exception in thread “main” javax.xml.ws.soap.SOAPFaultException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
at $Proxy43.getEmployee(Unknown Source)
at com.company.auth.client.Client.main(Client.java:25)
Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
… 2 more
Caused by: java.io.IOException: Not Found
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1962)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1865)
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:170)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:593)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
… 7 more
can you let me know how you deployed on outside server Tomcat and accessed services using this client. Out side means outside eclipse tomcat server.
Thanks
eduser
Ben said,
October 29, 2008 at 9:29 am
Hi Eduser,
You should choose “Run as Java Application”. “Run on Server” is meant for running a servlet.
I’m not sure from the stack trace you posted exactly what your problem is. Perhaps you can try the cxf-user mailing list: http://www.nabble.com/cxf-user-f16914.html
-Ben
eduser said,
October 31, 2008 at 7:09 am
Thanks for reply Ben….
I tried to run like that also “Run as Java Application” but no luck getting same as above error message.
is there any specific procedure we need to follow to run client to access this webservice?
Thanks
eduser
Ben said,
October 31, 2008 at 9:20 am
Hi Eduser,
All you should need to do is run the service on an application server such as JBoss or Tomcat and then run the client like a normal Java program.
Marcos de Sousa said,
November 13, 2008 at 3:33 am
Thanks for this tutorial. It worked for me.
Cheers,
Francisco said,
January 23, 2009 at 8:19 am
Thanks a lot for this tutorial i didn’t have any problem to make it run, thanks,
would you mind write another tutorial for restful web services in the same way
thanks again
Chetan said,
January 25, 2009 at 10:30 am
Hi,
I already have a web service which throws open SOAP interfaces for the clients. (Spring framework in use.)
Now I want to expose these services as REST interfaces. Can CXF help me? I guess it can as it has an inherent support for REST, but not sure how (REST to SOAP part and it’s integration with Spring). Can u please throw some pointers regarding this. Any help will be highly appreciated.
Thanks,
Jack said,
February 6, 2009 at 12:06 pm
Very useful and practical tutorial even 1 year later.
Dummy said,
April 2, 2009 at 2:40 pm
I’m getting this error… can anyone help please? This was working for me. I was able to see the WSDL. But suddenly this error started coming up. I’m using Eclipse 3.4.2
Apr 2, 2009 4:29:45 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@e86da0: display name [org.apache.cxf.bus.spring.BusApplicationContext@e86da0]; startup date [Thu Apr 02 16:29:45 CDT 2009]; root of context hierarchy
Apr 2, 2009 4:29:45 PM org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
Exception in thread “main” java.lang.NoClassDefFoundError: com/sun/xml/fastinfoset/stax/StAXDocumentParser
at org.apache.cxf.bus.spring.TunedDocumentLoader.loadFastinfosetDocument(TunedDocumentLoader.java:144)
at org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.fastInfosetLoadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:164)
at org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.loadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:126)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:109)
at org.apache.cxf.bus.spring.BusApplicationContext.loadBeanDefinitions(BusApplicationContext.java:263)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
at org.apache.cxf.bus.spring.BusApplicationContext.(BusApplicationContext.java:91)
at org.apache.cxf.bus.spring.SpringBusFactory.createApplicationContext(SpringBusFactory.java:102)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:93)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:86)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:64)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:53)
at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:69)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:106)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:97)
at org.apache.cxf.endpoint.AbstractEndpointFactory.getBus(AbstractEndpointFactory.java:73)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.initializeServiceFactory(AbstractWSDLBasedEndpointFactory.java:228)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:99)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:52)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:102)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:115)
at com.idearc.creditcardauth.client.Client.main(Client.java:23)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.fastinfoset.stax.StAXDocumentParser
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
… 26 more
Jim said,
April 7, 2009 at 11:54 am
Hi Ben,
Could you put a tar ball of whole mvn building project ? I am having problem here and there, but I think if I have your the tar ball and look into that, I should be able to figure that out
Thanks
Ben said,
April 7, 2009 at 12:41 pm
Hi Jim,
I just used Eclipse to build this project. I still haven’t gotten around to learning Maven yet. I’m afraid I lost the original code in a hard drive crash before I backed it up, so I only have what’s posted here.
ICE-LIGHT said,
June 4, 2009 at 2:51 am
HI
I have a question !
why we must import a service and the bean in the client classe
import com.company.auth.bean.Employee;
import com.company.auth.service.AuthService;
Tanks for a Tutoriel
it is an advantage for cxf or not ???
Chris said,
June 4, 2009 at 8:50 am
Hi Ben,
Compliments for the tutorial. Very well explained. I was wondering whether you could help me with this problem …
I have a service with 3 methods …
1) Method that returns a String.
2) Method returning a void but that does something.
3) Method that does something and returns a List of Objects.
I am using Apache Tomcat 6.0.13 as an application server.
I have built a Client program which I am running on eclipse to test my service. The first method work fine. The third method also seems to work fine on the server. In fact all the logs shows that everything is working fine. Even the soap XML on Tomcat’s console seems to be correct. The problem is here …
Say the 3rd method is supposed to return a list with ‘X’ objects in it … the client always receives a list with ’1′ object, irrespectively of ‘X’ and also all the fields of that object are null. My complex object does implement the Serializable interface.
Thanks
Ben said,
June 4, 2009 at 11:46 am
ICE-LIGHT, in Java, you must import all referenced classes that are located in a different package.
Chris said,
June 5, 2009 at 2:44 am
Ok problem solved … thing is that if you’re using Aegis on the Server Side, you also have to use it on the Client side.
A single line of code did the trick:
proxyFactory.setDataBinding(new AegisDatabinding());
batman said,
August 25, 2009 at 2:37 am
great tutorial!!! it worked first time, out of the box – using tomcat 6.0, cxf2.3.
10 minutes to get it up and running.
many thanks!
Ashwin said,
September 13, 2009 at 7:11 pm
Hi Ben,
I was trying to run the above example. I am getting the following error. I am using cxt 2.2.3. I have all the jars .
deploy\Hygeia.war\WEB-INF\lib\geronimo-servlet_2.5_spec-1.2.jar) – jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2009-09-13 22:05:27,005 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/Hygeia]] Initializing Spring root WebApplicationContext
2009-09-13 22:05:32,823 ERROR [STDERR] Sep 13, 2009 10:05:32 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://service.auth.company.com/}corporateAuthService from class com.company.auth.service.AuthService
2009-09-13 22:05:34,415 ERROR [STDERR] Sep 13, 2009 10:05:34 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server’s publish address to be /swAuth……
In the web.xml ,I have added the following tags to the existing ones.
contextConfigLocation
classpath:com/company/auth/service/cxf.xml
CXFServlet
org.apache.cxf.transport.servlet.CXFServlet
CXFServlet
/services/*
Any Ideas please???
Jugash said,
September 24, 2009 at 9:53 am
I faced the same problem that Dom was facing earlier “org.apache.cxf.interceptor.Fault: Marshalling Error:”. I know the post is very old but I am putting here the solution that worked for me for the benefit of anyone else who is stuck with the same problem. The problem for me was that the default constructor was not defined and ObjectInstatntiation was failing. The default data binding class was not giving a very friendly message but when i changed to aegis it gave me an InstantiationException.
jaime said,
October 22, 2009 at 10:12 am
Is that a valid procedure to create a cxf client for a web service exposed by other platform as .net??
jerome bulanadi said,
November 12, 2009 at 1:31 am
I was looking for articles on how to deploy cxf on a web server instead of an Endpoint.publish on a single port.
I was able to run your sample on Apache Tomcat. It worked with multiple webservices on the same tomcat port.
Great tutorial.
Thanks a lot!
Leo said,
November 16, 2009 at 10:44 am
Hello, Ben..
first of all: thanks for the great article!
Can you help with this error:
WARNING: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at $Proxy45.getEmployee(Unknown Source)
I think it’s a java doubt and not ws: How can I put a Employee, so when I call (AuthService) factory.create().getEmployee(“0223938″) it returns the right Employee and not the Unknown Source Error?
Thanks in advance!
John said,
January 19, 2010 at 1:51 pm
Ben
Instead of CXF generate the wsdl on the fly and have that displayed on the UI when we go to below url.
http://localhost:7001/authManager/services/servicename?wsdl
Is there a way to generate one using java2wsdl and package it in the war and have url refer to the packaged wsdl rather than auto-generated wsdl?
One difference i am seeing between the two wsdl is the one CXF generates automatically imports another wsdl that has types, messages and operations defined in it.
-John
satheesh said,
February 25, 2010 at 6:40 am
Really great tutorial!! amazing . I did it with out even a single error.
Thanks a million!
Great!
alexas said,
June 13, 2010 at 5:46 pm
great first steps tutorial abt cxf and web srvces. thank you!
alex said,
June 22, 2010 at 10:03 am
thanks for the great article!
i have one question. in the client side we should enter this code:
factory.setAddress(“http://IPAddressOfTheServer:PortNember/serviceName”);
to invoke the web service
but in my case, to access to the web from the client Machine we should pass by a web proxy. how can I enter the ip adress of the web proxy using in the class Client
alex said,
July 6, 2010 at 2:56 pm
Hi Ben,
Your client example contains factory.setServiceClass(AuthService.class);
If I’m not mistaken AuthService class is part of your web service. If so then your client is tightly coupled with the web service implementation which is a ‘no-no’. Clients shouldn’t care about service implementations. All they need to know is WSDL. Here is an example of what i mean http://www.opendocs.net/apache/cxf/2.0/developing-a-consumer.html.
Thanks Ben!
chandan Agarwal said,
September 20, 2010 at 9:02 am
Hello i am in an urgent need of help. its been a week but i am not able to figure out the problem;
I first converted wsdl to java and then created a jar file in MAVEN using apache cxf. I am using jonas server. When i run the client i get the following result
2010-09-20 15:04:37,167 : LoggingOutInterceptor$LoggingCallback.onClose : Outbound Message
—————————
Encoding: UTF-8
Headers: {SOAPAction=[""], Accept=[*]}
Messages:
Payload:
10072601/10072
60100000001fr_FR1WSS-ATOL2032309
————————————–
2010-09-20 15:04:37,558 : LoggingInInterceptor.logging : Inbound Message
—————————-
Encoding: UTF-8
Headers: {connection=[close], Date=[Mon, 20 Sep 2010 13:04:30 GMT], transfer-encoding=[chu
nked], Server=[Apache], content-type=[text/xml;charset=utf-8]}
Messages:
Message:
Payload: ns1:ClientNo such operation ‘getB
illingPeriodRangeRequest’dvedv332
The error is in this line –> No such operation ‘getBillingPeriodRangeRequest’
Its really strange coz it is looking for an operation which doesnt exist and which it shldnt be looking for this. Is ther anything wrong with my wsdl.
The client code is:
JaxWsProxyFactoryBean factory = new org.apache.cxf.jaxws.JaxWsProxyFactoryBean();
factory.setServiceClass(GetBillingPeriodRange.class);
factory.setAddress(attributes.getWsURL().toString());
factory.getInInterceptors().add(new org.apache.cxf.interceptor.LoggingInInterceptor());
factory.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
GetBillingPeriodRange billingService = (GetBillingPeriodRange) factory.create();
result=billingService.manageGetBillingPeriodRange(request);
My wsdl is:
chandan Agarwal said,
September 20, 2010 at 9:04 am
Hello i am in an urgent need of help. its been a week but i am not able to figure out the problem;
I have done exactly what you told. I have been able to successfully generate the .jar file with dependencies; I am using jonas server. When i run the client i get the following result
2010-09-20 15:04:37,167 : LoggingOutInterceptor$LoggingCallback.onClose : Outbound Message
—————————
Encoding: UTF-8
Headers: {SOAPAction=[""], Accept=[*]}
Messages:
Payload:
10072601/10072
60100000001fr_FR1WSS-ATOL2032309
————————————–
2010-09-20 15:04:37,558 : LoggingInInterceptor.logging : Inbound Message
—————————-
Encoding: UTF-8
Headers: {connection=[close], Date=[Mon, 20 Sep 2010 13:04:30 GMT], transfer-encoding=[chu
nked], Server=[Apache], content-type=[text/xml;charset=utf-8]}
Messages:
Message:
Payload: ns1:ClientNo such operation ‘getB
illingPeriodRangeRequest’dvedv332
The error is in this line –> No such operation ‘getBillingPeriodRangeRequest’
Its really strange coz it is looking for an operation which doesnt exist and which it shldnt be looking for this. Is ther anything wrong with my wsdl.
The client code is:
JaxWsProxyFactoryBean factory = new org.apache.cxf.jaxws.JaxWsProxyFactoryBean();
factory.setServiceClass(GetBillingPeriodRange.class);
factory.setAddress(attributes.getWsURL().toString());
factory.getInInterceptors().add(new org.apache.cxf.interceptor.LoggingInInterceptor());
factory.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
GetBillingPeriodRange billingService = (GetBillingPeriodRange) factory.create();
result=billingService.manageGetBillingPeriodRange(request);
My wsdl is:
Michele said,
September 27, 2010 at 7:01 am
Thanks for the article man, the example worked wonders on my weblogic 10.3 server.
tutorial services said,
September 30, 2010 at 4:10 am
great tutorial!!! Really great tutorial!! amazing .
really thanks for it…
Bosman said,
October 19, 2010 at 1:23 pm
Question for any one. I have one service running fine using CXF with RAD7. I have a requirement to call another service that’s in a jar file from within my service. I have the wsdl for the other service, and I have generated the artifacts. However, I am not sure how to go about associating my service to this other service so that I can call it. Obviously, my service will act as a client of this new service. Please provide some assistance if anyone can.
Cheers!
Praniv said,
December 15, 2010 at 1:57 pm
Can u please upload your project. Can’t find the cxf-servlet.xml & cxf-extension-soap.xml.
Its very confusing. I an a newbie
Please help
Ricky said,
February 12, 2011 at 5:07 am
Thanks! This got me started. Perhaps the easiest for a newby like me is to use the Maven jax-ws archetype. It was a snap. Plus your example helped me put it all together.