It's quite possible (probable actually) that there is a mismatch between the
namespace expectations on client and server, especially if the interface and
impl are in different packages. Definitely add the namespace attributes to
the @WebService annotations on both client and server.
Next thing to note:
On the server side, you are configuring in the AegisServiceConfiguration, but
you aren't on the client the side. That might also cause an issue.
Barring those fixing it, if you can create a jir and attach the full test
case, that would be a help.
Dan
On Wed November 11 2009 12:45:50 pm ddyer wrote:
> My apologies for the length of the post, btu I decided to err on the side
> of completeness.
>
> I'm fairly new to using cxf (and web services in general). I'm currently
> trying to create a basic cxf/spring and hibernate web service and having a
> very strange behavior.
>
> When my test client calls the web service the argument (just a String)
> being passed in the message is there, but the implementation method is
> receiving null. I'm guessing that it must be a configuration issue, but I
> can't for the life of me see it.
>
> The service endpoint interface:
> -------------------------------
>
> @WebService
> public interface RetrieveUserService {
>
> public UserProfile retrieveUser(@WebParam(name="userName") String
> userName);
> public List<UserProfile> retrieveUsers(@WebParam(name="queryInput")
> String
> queryInput);
> }
>
> --------------------
>
> The relevant bits of the service endpoint implementation:
> -------------------------------------------------------
>
> @WebService(endpointInterface="com.artifact_software.portal.userws.services
> .RetrieveUserService") public class RetrieveUserServiceImpl implements
> RetrieveUserService {
>
> private Log _log = LogFactory.getLog(this.getClass());
> private UserWSController wsController;
>
>
>
> public UserProfile retrieveUser(String userName) {
> _log.debug("calling USERWS endpoint service to return profile
> for
> userName "+userName);
> UserProfile userProfile = wsController.findOneUser(userName);
> return userProfile;
> }
>
> public List<UserProfile> retrieveUsers(String queryInput) {
> List<UserProfile> userList =
> wsController.findUsersFromQuery(queryInput);
> return userList;
> }
>
> ----------------------------------------------------------
>
> Relevant Test Client code :
> -------------------------------
>
> public static void main(String args[]) throws Exception {
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>
> factory.getInInterceptors().add(new LoggingInInterceptor());
> factory.getOutInterceptors().add(new LoggingOutInterceptor());
> factory.setServiceClass(RetrieveUserService.class);
> factory.setAddress("http://localhost:8080/lms-user-ws/userws");
>
>
>
> factory.getServiceFactory().setDataBinding(new
> AegisDatabinding());
> RetrieveUserService client = (RetrieveUserService)
> factory.create();
>
> UserProfile response = client.retrieveUser("nsd100000");
>
> if (response != null){
> System.out.println("response not null");
> System.out.println("got user "+response.getUserName()+
> " with id "+response.getId()+
> " first name "+response.getFirstName()+
> " last name "+response.getLastName());
> System.exit(0);
> }
> else{
> System.out.println("got null response");
> }
> }
>
> --------------------------------------------------------------
>
> CONFIGURATION:
>
> Complete spring config file:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:cxf="http://cxf.apache.org/core"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://www.springframework.org/schema/context
>
> http://www.springframework.org/schema/context/spring-context-2.5.xsd
> http://cxf.apache.org/core
> http://cxf.apache.org/schemas/core.xsd
> http://cxf.apache.org/jaxws
> http://cxf.apache.org/schemas/jaxws.xsd"
> default-autowire="byName">
>
> <!-- Load CXF modules from cxf.jar -->
> <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" />
>
> <!-- Enable message logging using the CXF logging feature -->
> <cxf:bus>
> <cxf:features>
> <cxf:logging/>
> </cxf:features>
> </cxf:bus>
>
> <!-- The service bean -->
> <bean id="retrieveUserServiceImpl"
> class="com.artifact_software.portal.userws.service.impls.RetrieveUserServic
> eImpl"> <property name="wsController">
> <bean
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryB
> ean" scope="prototype">
> <property name="transactionManager">
> <ref bean="hibernateTransactionManager"
> />
> </property>
> <property name="target">
> <bean
>
> class="com.artifact_software.portal.userws.controller.UserWSControllerImpl"
> scope="prototype">
> <property name="userDAO"
> ref="lmsUserDao" />
> <property
> name="lmsUserToProfileConverter"
> ref="userToProfileConverter" />
> </bean>
> </property>
> <property name="transactionAttributes">
> <props>
> <prop
> key="*">PROPAGATION_REQUIRED</prop>
> </props>
> </property>
> </bean>
> </property>
> </bean>
>
> <!-- controller and helper beans so the service can do what it needs
> -->
>
>
> <bean id="userToProfileConverter"
> class="com.artifact_software.portal.userws.converters.LmsUserToProfileConve
> rter" />
> <bean id="lmsUserDao"
> class="com.artifact_software.portal.data.dao.impl.LmsUserDAOImpl"
> parent="com.artifact_software.portal.generic.common.DAOBaseImpl"/>
>
> <!-- Aegis data binding -->
> <bean id="aegisBean"
> class="org.apache.cxf.aegis.databinding.AegisDatabinding"
> scope="prototype"/>
> <bean id="jaxws-and-aegis-service-factory"
> class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
> scope="prototype">
> <property name="dataBinding" ref="aegisBean"/>
> <property name="serviceConfigurations">
> <list>
> <bean
> class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
> <bean
> class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
> <bean
> class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
> </list>
> </property>
> </bean>
>
> <!-- Service endpoint -->
> <!-- See http://incubator.apache.org/cxf/faq.html regarding CXF +
> Spring AOP -->
> <jaxws:endpoint id="retrieveUserService"
>
> implementorClass="com.artifact_software.portal.userws.service.impls.Retriev
> eUserServiceImpl" implementor="#retrieveUserServiceImpl"
> address="/userws">
> <jaxws:serviceFactory>
> <ref bean="jaxws-and-aegis-service-factory"/>
> </jaxws:serviceFactory>
> </jaxws:endpoint>
> </beans>
>
> -------------------------------------------------------------
> web.xml
>
> <web-app id="services" version="2.5"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
>
> <!-- Adding the Spring Context Listener. It will help to init Spring
> Context -->
> <listener>
> <listener-class>
> org.springframework.web.context.ContextLoaderListener</listener-class>
> </listener>
>
> <!-- Context file location of Spring -->
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/spring-config.xml,
>
> classpath:portal-events.xml</param-value>
> </context-param>
>
> <!-- CXF Servlet -->
> <servlet>
> <servlet-name>CXFServlet</servlet-name>
> <servlet-class>
> org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
> </servlet>
>
> <!-- Mapping with a URL Pattern -->
>
> <servlet-mapping>
> <servlet-name>CXFServlet</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
> ---------------------------------------------------------
>
> Outbound message:
>
> 1-Nov-2009 12:34:46 PM
> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: http://localhost:8080/lms-user-ws/userws
> Encoding: UTF-8
> Content-Type: text/xml
> Headers: {SOAPAction=[""], Accept=[*/*]}
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:retr
> ieveUser
> xmlns:ns1="http://services.userws.portal.artifact_software.com/"><ns1:user
> Name>nsd100000</ns1:userName></ns1:retrieveUser></soap:Body></soap:Envelope
> >
>
>
> but as stated above the implementation method is receiving a null object
> instead of the String value.
>
> What have I overlooked?
>
> Thanks in advance for your time and help,
>
> David.
>
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog