I still can't get this to work. I'm suspect it may have something to do with me
not having a package-info.java class in my classpath.
I Don't know that this does. I just noticed that the sample has one and I don't
and the fact that it says something about bindings and schema which is what
line 213 is looking for.
But when I add a package-info.java I get a exception trying to publish my rest
interface -
INFO: Creating Service
{http://channelstore.inform.atkinsglobal.com/}ChannelStoreRestServiceService
from class com.atkinsglobal.inform.channelstore.ChannelStoreRestService
Exception in thread "main" java.lang.NullPointerException
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createBareMessage(ReflectionServiceFactoryBean.java:557)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:234)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:246)
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:134)
at
org.apache.cxf.frontend.AbstractEndpointFactory.createEndpoint(AbstractEndpointFactory.java:83)
at
org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:84)
at
com.atkinsglobal.inform.channelstore.ChannelStoreImpl.init(ChannelStoreImpl.java:333)
at
com.atkinsglobal.inform.channelstore.ChannelStoreServer.main(ChannelStoreServer.java:35)
My package-info.java file contains the following -
@javax.xml.bind.annotation.XmlSchema(namespace =
"http://channelstore.inform.atkinsglobal.com",
elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.atkinsglobal.inform.channelstore;
Which matches the package name of my Service -
package com.atkinsglobal.inform.channelstore;
import javax.jws.WebParam;
import javax.jws.WebService;
import org.codehaus.jra.Get;
import org.codehaus.jra.HttpResource;
import com.atkinsglobal.inform.dataaccess.GetDataFault;
import com.atkinsglobal.inform.dataaccess.types.GetData;
@WebService
public interface ChannelStoreRestService
{
@Get
@HttpResource(location = "/rest/{xPathQuery}")
GetData getDataXPath(@WebParam(name = "GetDataXPathQuery")
GetDataXPathQuery query) throws GetDataFault;
}
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: Dan Diephouse [mailto:[EMAIL PROTECTED]
Sent: 21 June 2007 02:36
To: [email protected]
Subject: Re: REST & XPath
OK I spent some time digging into this - you may also want to see my post to
Willem.
Your test case works for me. I have to ask though - are you sticking an xpath
expression in the URL? If so, are you escaping it? If not, the additional "/"s
in the URL are likely to confuse the URI parser inside CXF.
As I understand URI templates, "/" is a sacred character and you can't have an
unescaped "/" inside data which you want mapped to your method parameter.
- Dan
On 6/20/07, Shaw, Richard A < [EMAIL PROTECTED]> wrote:
>
> 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
>
>
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog