Posts Tagged web services

Wiring a web service

I’m dabbling in web services setup, not really knowing what I’m doing yet, and here’s a situation I encountered today:

I was taking a prior example where the web service setup had been done for me, and adapting it for use with a new prototype. I had a WEB-INF/services.xml that looked like this:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:amq="http://activemq.org/config/1.0" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
		http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd"
	default-autowire="no">

	<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="myGreetingSvcEndpoint" implementor="#myGreetingSvc" address="/GreetingSvc" />

	<bean id="greetingSvc" class="com.example.svc.GreetingSvcImpl">
<property name="messageSender" ref="messageSender" />
	</bean>
</beans>

When I tried deploying this though, it was looking for a myGreetingSvc bean and couldn’t find it:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myGreetingSvcEndpoint': Cannot resolve reference to bean 'myGreetingSvc' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myGreetingSvc' is defined
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myGreetingSvc' is defined

Why would it be looking for a myGreetingSvc bean?  It seems that the implementor attribute of the jaxws:endpoint expects to reference a bean — replacing “#myGreetingSvc” with “#greetingSvc” on line 14 in services.xml (and correcting my @WebService annotation’s endpointInterface property in GreetingSvcImpl.java to match the name of the interface it was trying to point to) got it working.

I think a lot of how our service.xml is set up (how it’s Spring-like) is because we’re also using CXF, which I hear is Spring-aware.  There’s a lot I still don’t know about web services!

Advertisements

, ,

Leave a comment

Where’s that nest of WSDLs?

I wanted to access a WSDL or two on a .war project deployed on a local JBoss instance, as a quick test to see if I had broken the project with a recent change to one of its dependencies.  But I didn’t know how to find any of the WSDLs, and looking through the project (as well as the project it is depedent upon) didn’t seem to turn up any answers for me.

The URL for the nest-o-WSDLs turns out to be in the form:

http://localhost:8080/artifactId-version/

So for a project whose artifactId is foo-baz-snark and whose version is 0.9.6-SNAPSHOT, the URL of the page-o-WSDLs would be:

http://localhost:8080/foo-baz-snark-0.9.6-SNAPSHOT/

I still haven’t found where in the project this location is configured… perhaps it’s the default location (convention over configuration, you know!)

, ,

Leave a comment