Step by Step tutorial for CXF web service ?

2009-04-28 Thread sridhar veerappan
Hi,
I was trying for a step by step CXF configuration and inbuild wsdl which
comunicates with the web service.

Can anyone give a link or source code to go through that.

Thanks in Advance
Sridhar


Re: A rather crazy idea for a feature

2009-04-28 Thread Benson Margulies
Yes, that's precisely my idea. For the immediate case at hand, just mtom
would be useful. I see your point about the whole (oink) hog. Perhaps I can
get Tatu excited about the Woodstox end of this.

On Tue, Apr 28, 2009 at 6:53 AM, Eoghan Glynn  wrote:

> Hi Benson,
>
> Do you mean using an NIO MappedByteBuffer?
>
> That would be an interesting thing to look at doing.
>
> Obviously limiting it to MTOM attachments sortta simplifies things,
> but of course there's also the possibility to go the whole hog and
> write a full-blown transport based on shared memory. Now in a previous
> life, I had great fun adding NIO support to a commercial CORBA ORB.
> One lesson learned from the experience was that to fully leverage the
> potential efficiency gains from NIO, one must marshall *directly* into
> an NIO buffer as opposed to some intermediate representation. So for a
> full-blown transport option, we would probably need to layer a
> java.io.{In|Out}Stream implementation over the NIO buffer to
> facilitate efficient StAX-based (parse|write} of the XML. Also some
> carefull thought would need to be put into the impact of asynchrony on
> the read side, dealing with the partial availability of data for
> incoming events etc. In the CORBA case there was lots of complexity
> around alignment and boundaries in the encoding and non-atomic reads
> of primitives, but I guess all that would be avoided in this case as
> it sort of fell out from the binary nature of the GIOP protocol.
>
> Cheers,
> Eoghan
>
>
> 2009/4/28 Benson Margulies :
> > Imagine a CXF extension to MTOM that used shared memory to move the
> > attachment. The bytes from the DataSource or whatever would be pushed
> into a
> > mapped file, and the client would map the same file. Maybe this is just
> the
> > file: URL as the MTOM identifier, and the mapping of the file is just an
> > opimization on top of that.
> >
>


Re: A rather crazy idea for a feature

2009-04-28 Thread Eoghan Glynn
Hi Benson,

Do you mean using an NIO MappedByteBuffer?

That would be an interesting thing to look at doing.

Obviously limiting it to MTOM attachments sortta simplifies things,
but of course there's also the possibility to go the whole hog and
write a full-blown transport based on shared memory. Now in a previous
life, I had great fun adding NIO support to a commercial CORBA ORB.
One lesson learned from the experience was that to fully leverage the
potential efficiency gains from NIO, one must marshall *directly* into
an NIO buffer as opposed to some intermediate representation. So for a
full-blown transport option, we would probably need to layer a
java.io.{In|Out}Stream implementation over the NIO buffer to
facilitate efficient StAX-based (parse|write} of the XML. Also some
carefull thought would need to be put into the impact of asynchrony on
the read side, dealing with the partial availability of data for
incoming events etc. In the CORBA case there was lots of complexity
around alignment and boundaries in the encoding and non-atomic reads
of primitives, but I guess all that would be avoided in this case as
it sort of fell out from the binary nature of the GIOP protocol.

Cheers,
Eoghan


2009/4/28 Benson Margulies :
> Imagine a CXF extension to MTOM that used shared memory to move the
> attachment. The bytes from the DataSource or whatever would be pushed into a
> mapped file, and the client would map the same file. Maybe this is just the
> file: URL as the MTOM identifier, and the mapping of the file is just an
> opimization on top of that.
>


Need Help with JAX-WS and JAX-RS example

2009-04-28 Thread cybercxf

When I run the RestClient.java, it is giving me error 

java.lang.NoSuchFieldError: REQUEST_URI

Can someone help me, what should be the @Path. Is the code for using the
same service class (HelloWorldImpl.java) for both JAX-WS, JAX-RS?

Please see all the code below and let me know.

thanks.


Code



HelloWorld.java (Inteface)
===

import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.WebParam.Mode;

@WebService(name = "HelloWorld")
public interface HelloWorld {
void receive(@WebParam(name = "itemXML", mode = Mode.IN) String 
itemXML);
}

HelloWorldImpl.java
==

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

@Path("/HelloWorld")
@WebService(endpointInterface = "org.openpipeline.services.HelloWorld",
serviceName = "HelloWorld")
@Consumes("application/xml")
public class HelloWorldImpl implements HelloWorld{
@WebMethod
@POST
@Path("/receive")
public void receive(@PathParam("*/*")String itemXML) {
System.out.println(itemXML);
}
}

Server.java


import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

public class Server {
public static void main(String[] args){
HelloWorldImpl implementor = new HelloWorldImpl();

/*
 * Start JAX-WS service
 */
JaxWsServerFactoryBean svrFactory = new 
JaxWsServerFactoryBean();
svrFactory.setServiceClass(HelloWorld.class);
svrFactory.setAddress("http://localhost:9000/";);
svrFactory.setServiceBean(implementor);
svrFactory.create();

/*
 * Start JAX-RS service
 */
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(HelloWorldImpl.class);
sf.setResourceProvider(HelloWorldImpl.class, 
new SingletonResourceProvider(new HelloWorldImpl()));
sf.setAddress("http://localhost:9001/";);

sf.create();

}
}


RestClient.java


import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;

public class RestClient {

public static void main(String args[]) throws Exception {

PostMethod post = new
PostMethod("http://localhost:9001/HelloWorld/receive/";);
post.addRequestHeader("Accept", "application/xml");
RequestEntity entity = new StringRequestEntity("Hello 
REST!",
"application/xml", "ISO-8859-1");
post.setRequestEntity(entity);
HttpClient httpclient = new HttpClient();

try {
int result = httpclient.executeMethod(post);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
} finally {
// Release current connection to the connection pool 
once you are
// done
post.releaseConnection();
}

System.out.println("\n");
System.exit(0);
}
}

Client.java 


public class Client {
public static void main(String[] args){
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(HelloWorld.class);

factory.setAddress("http://localhost:9000/HelloWorld";);
HelloWorld client = (HelloWorld) factory.create();
Item item = new Item();
item.importXML("Hello");
client.receive(item.toString());
}
}

-- 
View this message in context: 
http://www.nabble.com/Need-Help-with-JAX-WS-and-JAX-RS-example-tp23287998p23287998.html
Sent from the cxf-dev mailing list archive at Nabble.com.