I'm currently writing a few applications that contain web service clients and servers, as complete standalone applications, eg without any web application server / servlet engine. I'm using plain Java 6, and for the "server" part I'm using the sun HttpServer. Working like a charm.
(actually I am using CXF, but only for their wsdl2java tool, which is more flexible than the one that ships with Java 6).
I've been wondering now if there is any benefit for me to look at frameworks like CXF. Strangely enough, I can't find any information on the CXF web site on such a scenario, they just seem to blindly assume that everybody uses an applications server (and worse, maven).
One of the reasons why I'm looking at CXF is that in the near future I expect that I need to support AIX as well, and there I can't use:
reqcontext.put(BindingProviderProperties.CONNECT_TIMEOUT, connect_timeout);
reqcontext.put(BindingProviderProperties.REQUEST_TIMEOUT, request_timeout);
CXF has this thing called an HTTPClientPolicy which would nicely fit the bill.
Does anybody have any links to articles discussing using CXF without any application server / servlet engine? Are there any other benefits that CXF could give me over the current Java 6 JAX-WS implementation?
Maarten
Almost all the samples that come in the CXF distribution are setup specifically as a "main method" type service that starts up the service and clients and such as standalone applications without any use of an app server (or even Tomcat). The CXF samples would be a good place to start.
That said, they do all use Maven now. :-)
Related
Do I have been writing a java application, application is a console application.
Now, I want my application to listen to request at a port coming from web application and process those request and affect DB data.
I am not sure how to do it in a simple java project. Can I use some java webservices, and how?
Socket programming in Java is quite nice - a Socket is an abstraction that listens for data coming in on a single port from a single web address or server and can also send out.
http://zerioh.tripod.com/ressources/sockets.html
Note that listening for data blocks program flow.
Most likely you're looking at learning Java Servlet programming. There are a lot of good resources to learn from.
However, from my experience something like Netty could serve you really well from both learning and actual application development perspectives. The site contains very reasonable example driven documentation, which takes user from non-blocking TCP/IP programming to HTTP support.
Yes , web service API (JAX-WS 2.0) is added to the Java SE 6. You can use these API to create a simple web service for the Java SE application.
See the section "Using JAX-WS 2.0 to Create a Simple Web Service" for the example .It shows how to create a standard web service end-point using JAX-WS 2.0 for the Java SE application.
Beside , this 5 minutes tutorial is very good at introducing JAX-WS .It includes the demo for implementing the web-service end-point and client and provide the eclipse project source code to download too. Please note that it misses the step to use wsgen to generate the service classes for the WebService end-point ,but it is not so difficult to figure out how to use wsgen
Hi guys is there a way to self-host a web service in Java just like WCF?
Jersey using Grizzly embedded within it would seem like a good fit for your needs. It wouldn't require and outside application server and would be fairly lightweight to get setup. You can just read the Jersey getting started documents to get going with that exact path:
Jersey User Guide
If by self-hosting you mean generating a web service endpoint for invocation, there are a number of ways to go on this, depending on your potential deployment environment.
I'd start off looking at Oracle's JAX-WS implementation, which includes RESTful capabilities. If you want to run a relatively simple stack, you could use Apache Axis2. And then JBoss has JBossWS, which can run standalone or in the JBoss Application Server. I'm pretty sure most of the major application server engines have a Web Services component as well.
I have a web service that is using:
Java (familiar)
SOAP (new to me)
JBOSS (new to me)
The web service is currently unsecure. My task is to make it secure using https (ssl or tsl).
I am new to web services and web things in general. In the last week have gone through a tone of literature. Much of it which I think was not relevant to my project. I think that I need two things:
A pretty basic tutorial on web services (java specific)
A tutorial on making web services secured
Here are some of the tutorials I have gone through already:
SO Answer - In-process SOAP service server for Java
How to make a web service server.
Does not have instructions for the client.
Also does not specify what should happen so I am not certain that I got the propper result when navigating to the URL.
An Introductory Tutorial on Web Services, Java and XML
Pretty good description of lots of xml things and how messages are passed. Not certain but this seems more low level than what I need
Three Minutes to a Web Service
Good tutorial but in the second step one of the commands did not work.
I think that this may be because the tutorial is really old and maybe my jdk is differnt or something like that..
You can check out these frameworks
Apache axis
Apache cxf
The web service is currently unsecure. My task is to make it secure using https (ssl or tsl).
If it's just about (one-way) SSL, then this question doesn't have much to do with web services actually. It's more a web server or app server configuration issue. For JBoss, see SSLSetup or, if you are using Apache for the SSL encryption, see Apache SSL/TLS Encryption.
I would guess that you need to look at JBoss's documentation for how they handle security. Maybe this would help:
Chapter 8. Security on JBoss
how hard is adding a basic web services interface to an existing java server application without having to turn it into a .war, or embedding a small web server like jetty?
say, xml-rpc instead of more modern approaches, if it helps.
if not too hard, can you suggest a starting point?
thank you in advance :)
It sounds like you're asking for the impossible: expose an HTTP service without plugging into or embedding an HTTP server!
Unless you want to reimplement what Jetty already does, I'd reccommend using Jetty as a library. That way you don't need to conform to the more awkward aspects of the Servlet spec. E.g. your servlets can have real constructors with parameters.
There is also a simple HTTP server implementation in JDK 6, but it's in the com.sun namespace so I'd avoid it for production code.
Check out the Restlet API which provides a painless way to implement RESTful web services that can run inside a web container or standalone.
I don't know what you are doing, but what about rmi?
RMI # stackoverflow
Spring-WS has the facility for using JRE 1.6's embedded web server, if that's an option for you. Spring-WS gives you a very nice SOAP server layer, if that's what you're after.
If not, then an embedded Jetty instance is probably the best idea.
I'm looking for a straightforward example / tutorial for implementing a JAX-WS (soap1.1 and soap1.2) web service based on wsdl definition using spring, axis2 and tomcat.
hint anyone ?
-- Yonatan
There is no such thing as "straightforward" in the world of SOAP. Any example and tutorial is bound to be complex due to the overengineered nature of this beast.
If you can choose your technologies, I'd recommend putting axis aside, and using Tomcat 6 + Java 6 + Metro. Metro is Sun's latest, greatest Java web services (jax-ws) stack. Coupled with JavaEE annotations, it's a relatively painless way to get a web service off the ground quickly.
Sorry to not answer the question directly.
Unfortunately, even the latest version of Metro has issues with tomcat and JDK6
I tried running the sample app on my machine and documented few issues I faced and resolved.
For others benefit please check here :
Running Metro + Tomcat 6 + JDK 6
The NetBeans IDE is good place to start. Enable the Axis2 Support in NB plug-ins. You can create a JAX-WS based Web Service from the WSDL (assuming you are using contract first) and the JAX-WS based WS client too. If you dont like what NetBeans generates or its deployment strategy, you can still build upon the code that it has generated
Axis2 does not support Spring web services when using Jax-WS. See this mailing list post:
http://markmail.org/message/hohdmsupo3r3gltl?q=list:org%2Eapache%2Ews%2Eaxis-user+spring+jax-ws
To do this you will need a custom module to add a BeanFactory into the MessageContext and then retrieve it out in your web service. Or you might write a custom dispatcher.