Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:40:28+00:00 2026-06-07T18:40:28+00:00

I have a multi-module project using Maven. On one of the modules I have

  • 0

I have a multi-module project using Maven. On one of the modules I have several web services developed using Apache CXF Framework 2.5.4. At the moment I have two “problems” or questions.

First of all, if I call to a method of one of the web services that should return a List, if the list is empty, it returns “null” instead of the empty list.
I was trying to find out what could be the problem, if it’s a bug of the CXF version I’m using or if I should use some annotation to modify the definition of the method or the response, but I couldn’t find anything. I’ve seen some people with the same problem, but no solution.

The other thing I wanted to ask is: I’m developing a web application using MVC pattern. I’m wondering which way I should call the web service from the Controller instead of using ClasspathXmlCpplicationContext and then context.getBean().

For example, the bean definition for one of the web services on the client side is:

<jaxws:client id="deviceWSClient"
        serviceClass="..IDeviceWebService"
        address="http://localhost:8080/../DeviceWS" /> 

I’ve already tried usin @Autowired or @WebServiceRef annotations. With these it works but not doing a HTTP request to the web service, I guess it gets the dependency from the local repository. I think what I need is the way of injecting this bean on the Controller.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:40:30+00:00Added an answer on June 7, 2026 at 6:40 pm

    To answer your questions

    For your first question: If the list is empty it is correctly handled by CXF version 2.6.1 – the service returns a empty. Just to demonstrate I have a sample service where types are defined this way:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlRootElement(name = "MemberSearchResponse", namespace="http://bk.org/memberservice/" )
    public class MemberSearchResponse {
    
        @XmlElementWrapper(name="memberDetails")
        private List<MemberDetail> memberDetails;
    

    If I return a empty memberDetails above, the xml that goes over the wire is this:

        <ns2:searchMemberResponse xmlns:ns2="http://bk.org/memberservice/">
            <ns2:MemberSearchResponse>
               <memberDetails/>
            </ns2:MemberSearchResponse>
        </ns2:searchMemberResponse>
    

    EDIT

    It is correctly handled as part of a wrapper type like above, but DOES return null if instead of returning a wrapper type, the list is directly returned.

    Consider a Webservice interface defined this way:

    @WebMethod(operationName = "searchMember")
        List<MemberDetail> searchMember(@WebParam(name = "MemberSearchRequest") MemberSearchRequest memberSearchRequest);
    

    If the List returned is an Empty list, it gets serialized as null by CXF 2.6.1 also.

    The workaround is to use a wrapper type

    EDIT END

    For your second question:

    You are creating a client bean this way:

    <jaxws:client id="deviceWSClient"
            serviceClass="..IDeviceWebService"
            address="http://localhost:8080/../DeviceWS" /> 
    

    Once you have created a Spring bean this way, you can treat it just like a normal Spring bean and inject it the way you would do with any normal Spring bean, for eg, either inject it this way:

     <bean id="consumerBean" class="...">
        <property name="deviceWS" ref="deviceWSClient">
     </bean>
    

    or use @Autowired

    @Autowired IDWebService deviceWSClient
    

    Or user @Resource

    @Resource IDWebService deviceWSClient
    

    These are the usual ways of injecting in a bean.

    I have a sample application at this github location that you can play with:
    https://github.com/bijukunjummen/memberservice-codefirst.git

    Just start up the server using mvn tomcat:run and run a test org.bk.memberservice.TestCxfIntegrationTest which will make a request to the CXF service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using soapUI maven plugin to create a multi-module maven-soapUi project. I have
I have a multi module web project. Four modules of the project are packaged
Basically, I have a multi-module project consisting of 5 different modules. One of the
I have a multi-module Maven project that is a Java web application. I am
I have a huge multi-module project , which is being built using maven. Most
We have a rather complicated multi-module Maven project. There are Flex modules, GWT modules,
We have a non-trivial multi-module maven project, then have a single module maven web-app
We are using maven with eclipse. We have a multi module project, quite big.
I have a multi module Spring project that I set up using Maven: my-root
I have a multi module project consisting of several jar modules and a war

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.