views:

238

answers:

3

I've developed a web service with jax-ws and Spring using the tutorials at the jax-ws commons website. It shows you how to define and reference your service from your spring applicationContext file (https://jax-ws-commons.dev.java.net/spring/).

What is the reason for the "#" when referencing the web service? I would expect to see something more like

<ws:service name="myEventWS" ref="eventWebService"/> 

but following example at the above link I created the following which works.

<bean id="eventWebService" class="com.myws.EventWS">
    <property name="model" ref="EventModel"/>
</bean>

<wss:binding url="/EventWS">
    <wss:service>
        <ws:service bean="#eventWebService"/>
    </wss:service>
</wss:binding>
+1  A: 

<ws:service> is using a custom configuration namespace, which is a feature of Spring which allow you to express complex bean graphs using simpler namespace. The meaning and interpretation of these custom namespaces is down to the implementation in question, in this case the JAX-WS-Commons project. It seems the authors of that decided that bean=#eventWebService means what you refer to as ref="eventWebService".

I don't know whay they did it that way, maybe they thought it was more readable... maybe they thought that bean=eventWebService (without the hash) means a name, rather than a reference... I don't know. The documentation isn't very clear either.

Either way, I'm pretty sure sure it's not a core Spring syntax, nor a convention that I've seen before.

skaffman
A: 

the "#" tells the bean that it's not a class, but rather a ref.

HTH

Amro
A: 

#eventWebService refers to the bean of type EventWebService (according to the default Spring naming convention when bean is is not specified).

Pascal Thivent