My service is as follows -
@WebService
public interface ChannelStoreRestService { @Get @HttpResource(location
= "/rest/{xPathQuery}") GetData getData(@WebParam(name =
"GetDataQuery") GetDataQuery query) throws GetDataFault; }
My bean is -
@XmlRootElement(name = "GetDataQuery") public class GetDataQuery {
private String xPathQuery; public String getXPathQuery() {
return xPathQuery;
}
public void setXPathQuery(String _xPathQuery) {
xPathQuery = _xPathQuery;
}
}
My implementation looks like -
@WebService(endpointInterface = "
com.atkinsglobal.inform.channelstore.ChannelStoreRestService")
public class ChannelStoreRestImpl implements ChannelStoreRestService {
public GetData getData(GetDataQuery query) throws GetDataFault
And I create the service as follows -
// Publish the rest interface
ChannelStoreRestImpl restImpl = new ChannelStoreRestImpl(this);
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceClass(ChannelStoreRestService.class);
sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
sf.setAddress(channelStoreEndpointUrl + "/xml/");
sf.getServiceFactory().setInvoker(new BeanInvoker(restImpl));
sf.getServiceFactory().setWrapped(false);
sf.create();
What isn't clear is which names need to match e.g. does the {} bit of
"/rest/{xPathQuery}") need to match xPathQuery in the bean ?
BTW - I also get another error is I set my location to "/{xPathQuery}"
- it says unexpected '/' at index 0.
Richard
________________________________
From: Dan Diephouse [mailto: [EMAIL PROTECTED]
Sent: Tue 19/06/2007 19:05
To: [email protected]
Subject: Re: REST & XPath
Can you paste what your annotated method and configuration code look like?
Its a bit hard to figure it out just based on the annotation. Thanks,
- Dan
On 6/19/07, Shaw, Richard A < [EMAIL PROTECTED]> wrote:
I can't get this to work. I get the error below.
I looked at the code and it seems to be something to do with XML schema.
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
at
org.apache.cxf.binding.http.IriDecoderHelper.buildDocument(
IriDecoderHelper.java:213)
at
org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.merg
eParams
(URIParameterInInterceptor.java:129)
at
org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.hand
leMessage
(URIParameterInInterceptor.java:105)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:147)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage (
ChainInitiationObserver.java:63)
at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequ
est(
JettyHTTPDestination.java:253)
at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService (
JettyHTTPDestination.java:213)
at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(
JettyHTTPHandler.java:54)
at org.mortbay.jetty.handler.ContextHandler.handle (
ContextHandler.java:712)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(
ContextHandlerCollection.java:211)
at org.mortbay.jetty.handler.HandlerWrapper.handle (
HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest(
HttpConnection.java:502)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(
HttpConnection.java:821)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable
(HttpParser.java
:208)
at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java
:378)
at org.mortbay.io.nio.SelectChannelEndPoint.run(
SelectChannelEndPoint.java :368)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(
BoundedThreadPool.java:442)
19-Jun-2007 14:37:17 sun.reflect.NativeMethodAccessorImpl invoke0
SEVERE: EXCEPTION
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(
AbstractList.java:449)
at
java.util.AbstractList$ListItr.previous(AbstractList.java:463)
at
org.apache.cxf.phase.PhaseInterceptorChain$PhaseInterceptorIterator.pr
evious
(PhaseInterceptorChain.java:438)
at org.apache.cxf.phase.PhaseInterceptorChain.unwind(
PhaseInterceptorChain.java:231)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:161)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage (
ChainInitiationObserver.java:63)
at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequ
est(
JettyHTTPDestination.java:253)
at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService (
JettyHTTPDestination.java:213)
at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(
JettyHTTPHandler.java:54)
at org.mortbay.jetty.handler.ContextHandler.handle (
ContextHandler.java:712)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(
ContextHandlerCollection.java:211)
at org.mortbay.jetty.handler.HandlerWrapper.handle (
HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest(
HttpConnection.java:502)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(
HttpConnection.java:821)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable
(HttpParser.java
:208)
at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java
:378)
at org.mortbay.io.nio.SelectChannelEndPoint.run(
SelectChannelEndPoint.java :368)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(
BoundedThreadPool.java:442)
Richard Shaw
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤
Richard Shaw
Technical Design Authority - Information Solutions Consultancy
Intelligent Transport Systems
Atkins Highways and Transportation
Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
Tel: +44 (0) 1372 756407
Fax: +44 (0) 1372 740055
Mob: 07740 817586
E-mail: [EMAIL PROTECTED]
www.atkinsglobal.com/its
-----Original Message-----
From: Freeman Fang [mailto:[EMAIL PROTECTED]
Sent: 19 June 2007 09:45
To: [email protected]
Subject: Re: REST & XPath
Hi Richard,
Yes, you can do it with rest binding.
First you need a service interface, some thing like @WebService
public interface BookService {
@Get
@HttpResource(location = "/dataaccess/{query}")
Book getQuery(@WebParam(name = "GetQuery")
GetQuery query) throws BookNotFoundFault; }
And then a service impl
@WebService(endpointInterface = "
org.apache.cxf.customer.book.BookService
")
public class BookServiceImpl implements BookService {
public Book getQuery(GetQuery query) throws BookNotFoundFault {
// you can get xpath from query and finish your
functionality
String xpath = query.getQuery();
}
}
And then the GetQuery bean which contain your xpath
@XmlRootElement(name
=
"XPathQuery") public class GetQuery {
private String query;
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
}
After publish your service by means of
BookServiceImpl serviceObj = new BookServiceImpl();
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceClass(BookService.class);
// Use the HTTP Binding which understands the Java Rest
Annotations
sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
sf.setAddress("http://localhost:9080/xml/");
sf.getServiceFactory().setInvoker(new BeanInvoker(serviceObj));
sf.getServiceFactory().setWrapped(false);
sf.create();
Finally you can access your service in rest way
http://localhost:9080/xml/dataaccess/yourxpathstring
Thanks very much
Freeman
Shaw, Richard A wrote:
I'm not sure if this is a rest interface or not but could somebody
advise me on how to do the following -
My request should look like this -
http://localhost/dataaccess/xpath
And my response is XML
The xpath bit of the request is used to access my data so my
function
(dataaccess) needs to be given the complete xpath string. Will the
rest interface do this for me ?
I'm expecting to use annotation like @HttpResource(location =
"/dataaccess/{query}")
Richard Shaw
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤
Richard Shaw
Technical Design Authority - Information Solutions Consultancy
Intelligent Transport Systems
Atkins Highways and Transportation Woodcote Grove, Ashley Road,
Epsom, Surrey, KT18 5BW
Tel: +44 (0) 1372 756407
Fax: +44 (0) 1372 740055
Mob: 07740 817586
E-mail: [EMAIL PROTECTED]
www.atkinsglobal.com/its
This email and any attached files are confidential and copyright
protected. If you are not the addressee, any dissemination of this
communication is strictly prohibited. Unless otherwise expressly
agreed
in
writing, nothing stated in this communication shall be legally binding.
The ultimate parent company of the Atkins Group is WS Atkins
plc. Registered in England No. 1885586. Registered Office Woodcote
Grove,
Ashley Road, Epsom, Surrey KT18 5BW.
Consider the environment. Please don't print this e-mail unless
you
really need to.
This message has been scanned for viruses by MailControl - (see
http://bluepages.wsatkins.co.uk/?6875772)
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog