You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by rm-ramos <rm...@criticalsoftware.com> on 2007/12/10 13:06:40 UTC

Can't route REST calls to methods using CXF2.0.3 and JBoss

Hi all,

I'm trying to deploy a very simple REST Webservice, using two Get methods:

@WebService(name="GetWorkOrderServiceRest",
targetNamespace="http://webservice.api.wow")
public class GetWorkOrderServiceRestImpl implements GetWorkOrderServiceRest
{

@Get
@HttpResource(location="/workorders")
public String getWorkorders() {
    return "hello world!";
}

@Get
@HttpResource(location="/workorder/{id}")
public String getWorkorder(@WebParam(name = "id")long id) {
    return "hello id:" + id;
}

..and though I *can* access the getWorkorders() method (via browser), I keep
getting the same error when I try to access, for instance, /workorder/123:
Invalid URL/Verb combination. Verb: GET Path: /workorder/123.

I've already tried to change the getWorkorder(id)'s HttpResource location to
/workorders/{id}, but that didn't work either as the first method, with no
arguments, was being called everytime I accessed the /workorders path.

Strange thing is I'm almost sure this was working, before I upgraded from
v2.0.0.
I would like to know if any of you guys understands what's going on. Am I
missing something here?!

Thanks in advance,
Rui Ramos


My remaining config files follow:

###
# applicationContext.xml
###
<jaxws:endpoint id="wowRest"
		  
implementor="com.criticalsoftware.wow.api.webservice.GetWorkOrderServiceRestImpl"
		   address="/rest"
		   bindingUri="http://apache.org/cxf/binding/http">
		  <jaxws:serviceFactory>
		    <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
                      <property name="wrapped" value="false" />
            </bean>
		  </jaxws:serviceFactory>
</jaxws:endpoint>


###
# beans.xml
###
<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<display-name>CXF Servlet</display-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>


###
# Interface (GetWorkOrderServiceRest)
###
@WebService
public interface GetWorkOrderServiceRest {

    String getWorkorders();
    String getWorkorder(long id);
    void addWorkorder(String person);
    void updateWorkorder(long id, String person);
    void deleteWorkorder(long id);

}


###
# The exception I get on the server
###
INFO: Invoking GET on /workorder/453
11:49:48,768 ERROR [STDERR] 10/Dez/2007 11:49:48
org.apache.cxf.phase.PhaseInterceptorChain doInterc
ept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination. Verb: GET
Path: /workorder/453
	at
org.apache.cxf.binding.http.interceptor.DispatchInterceptor.handleMessage(DispatchInterceptor.ja
va:74)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:73)
	at
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:79)
	at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:256)
	at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:123)
	at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:170)
	at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:152)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
(...)


-- 
View this message in context: http://www.nabble.com/Can%27t-route-REST-calls-to-methods-using-CXF2.0.3-and-JBoss-tp14251784p14251784.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Can't route REST calls to methods using CXF2.0.3 and JBoss

Posted by "Liu, Jervis" <jl...@iona.com>.
Cannot spot any obvious error in your code. Could you copy me the log messages when your server starts up, it should look like sth below:

2007-12-11 11:49:25 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://book.acme.com}BookServiceService from class org.apache.cxf.customer.book.BookService
2007-12-11 11:49:26 org.apache.cxf.binding.http.strategy.ConventionStrategy map
INFO: Mapping method getBooks to resource /books and verb GET
2007-12-11 11:49:26 org.apache.cxf.binding.http.strategy.ConventionStrategy map
INFO: Mapping method getBook to resource /books and verb GET
2007-12-11 11:49:26 org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http://localhost:9080/xml/
2007-12-11 11:49:26 sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
2007-12-11 11:49:26 sun.reflect.NativeMethodAccessorImpl invoke0
INFO: jetty-6.1.6
2007-12-11 11:49:26 sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Started SelectChannelConnector@0.0.0.0:9080
signal ready
server ready

Basically this information tell you what methods map to what resources and what HTTP verbs.

Thanks,
Jervis

> -----Original Message-----
> From: rm-ramos [mailto:rm-ramos@criticalsoftware.com]
> Sent: 2007年12月10日 20:07
> To: cxf-user@incubator.apache.org
> Subject: Can't route REST calls to methods using CXF2.0.3 and JBoss
> 
> 
> Hi all,
> 
> I'm trying to deploy a very simple REST Webservice, using two Get methods:
> 
> @WebService(name="GetWorkOrderServiceRest",
> targetNamespace="http://webservice.api.wow")
> public class GetWorkOrderServiceRestImpl implements
> GetWorkOrderServiceRest
> {
> 
> @Get
> @HttpResource(location="/workorders")
> public String getWorkorders() {
>     return "hello world!";
> }
> 
> @Get
> @HttpResource(location="/workorder/{id}")
> public String getWorkorder(@WebParam(name = "id")long id) {
>     return "hello id:" + id;
> }
> 
> ..and though I *can* access the getWorkorders() method (via browser), I
> keep
> getting the same error when I try to access, for instance, /workorder/123:
> Invalid URL/Verb combination. Verb: GET Path: /workorder/123.
> 
> I've already tried to change the getWorkorder(id)'s HttpResource location to
> /workorders/{id}, but that didn't work either as the first method, with no
> arguments, was being called everytime I accessed the /workorders path.
> 
> Strange thing is I'm almost sure this was working, before I upgraded from
> v2.0.0.
> I would like to know if any of you guys understands what's going on. Am I
> missing something here?!
> 
> Thanks in advance,
> Rui Ramos
> 
> 
> My remaining config files follow:
> 
> ###
> # applicationContext.xml
> ###
> <jaxws:endpoint id="wowRest"
> 
> implementor="com.criticalsoftware.wow.api.webservice.GetWorkOrderServi
> ceRestImpl"
> 		   address="/rest"
> 		   bindingUri="http://apache.org/cxf/binding/http">
> 		  <jaxws:serviceFactory>
> 		    <bean
> class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
>                       <property name="wrapped" value="false" />
>             </bean>
> 		  </jaxws:serviceFactory>
> </jaxws:endpoint>
> 
> 
> ###
> # beans.xml
> ###
> <servlet>
> 		<servlet-name>CXFServlet</servlet-name>
> 		<display-name>CXF Servlet</display-name>
> 		<servlet-class>
> 			org.apache.cxf.transport.servlet.CXFServlet
> 		</servlet-class>
> 		<load-on-startup>1</load-on-startup>
> </servlet>
> 
> <servlet-mapping>
> 		<servlet-name>CXFServlet</servlet-name>
> 		<url-pattern>/webservice/*</url-pattern>
> </servlet-mapping>
> 
> 
> ###
> # Interface (GetWorkOrderServiceRest)
> ###
> @WebService
> public interface GetWorkOrderServiceRest {
> 
>     String getWorkorders();
>     String getWorkorder(long id);
>     void addWorkorder(String person);
>     void updateWorkorder(long id, String person);
>     void deleteWorkorder(long id);
> 
> }
> 
> 
> ###
> # The exception I get on the server
> ###
> INFO: Invoking GET on /workorder/453
> 11:49:48,768 ERROR [STDERR] 10/Dez/2007 11:49:48
> org.apache.cxf.phase.PhaseInterceptorChain doInterc
> ept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination. Verb: GET
> Path: /workorder/453
> 	at
> org.apache.cxf.binding.http.interceptor.DispatchInterceptor.handleMessage(
> DispatchInterceptor.ja
> va:74)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
> hain.java:207)
> 	at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiation
> Observer.java:73)
> 	at
> org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDesti
> nation.java:79)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servlet
> Controller.java:256)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.ja
> va:123)
> 	at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServl
> et.java:170)
> 	at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServl
> et.java:152)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> (...)
> 
> 
> --
> View this message in context:
> http://www.nabble.com/Can%27t-route-REST-calls-to-methods-using-CXF2.
> 0.3-and-JBoss-tp14251784p14251784.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland