[ajug-members] Webservice with spring IoC

mike barnes mdb3624 at gmail.com
Wed Mar 9 14:45:09 EST 2011


I am having issues getting spring injection to work with my webservice.
Could someone help me understand what I am missing to get spring IoC working
with my project. Below is the web.xml,applicationContext.xml and source
code.

Thanks in advance:


web.xml
========================================================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     version="2.4"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Archetype Created Web Application</display-name>

  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

    <servlet>
        <servlet-name>HelloWorld</servlet-name>

<servlet-class>com.soltech.webservice.impl.HelloWorldImpl</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloWorld</servlet-name>
        <url-pattern>/HelloWorld</url-pattern>
    </servlet-mapping>


</web-app>
===============================================================================

applicationContext.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:p="http://www.springframework.org/schema/p" xmlns:context="
http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="
http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">

    <bean name="helloWorldService"
class="com.soltech.webservice.impl.HelloWorldImpl">
        <property name="serviceName" value="Account Service"/>
    </bean>

</beans>
====================================================================================

HelloWorld.java
====================================================================================
package com.soltech.webservice;

import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;

@WebService(name="HelloWorld")
public interface HelloWorld {

    @WebMethod
    @WebResult
    public String ping();

}
======================================================================================

HelloWorldImpl.java
======================================================================================
package com.soltech.webservice.impl;

import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;

import com.soltech.webservice.HelloWorld;

@WebService(name="HelloWorld")
public class HelloWorldImpl implements HelloWorld {


    private String serviceName;

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    @WebMethod
    @WebResult
    public String ping() {
        System.out.println("ServiceName=["+serviceName+"]");
        return "Service is up";
    }
}
==============================================================================================


When I call ping, my expectation is that I will see on the console
"ServiceName=[Account Service]" instead I see "ServiceName=[null]", I also
do not see any stack traces or anything else that would lead me to believe
that I had missed something.

Again
Any help would be appreciated.

Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ajug.org/pipermail/ajug-members/attachments/20110309/fc96e3f9/attachment.html 


More information about the ajug-members mailing list