Embedded Jetty and SOAP - java

I am trying to run an embedded Jetty and would like to expose a soap webservice. The project is loaded as a WAR generated by netbeans. The webservice is generated from a WSDL. What is the simplest way to add SOAP support to embedded Jetty

The axis2 web services framework can be deployed as a normal web application onto your embedded Jetty instance.
It provides a framework for the execution of your web service. You can embed such services within the Axis2 war file or deploy them separately .aar files (Special Axis2 archive file format)

It seems like there is a bridge to use JAX-WS with Jetty. Though I never use it personally.

Related

How to secure a SOAP web service with WSS with CXF

My application has a SOAP web service implemented using Apache CXF. I'm not using Spring or EJB, it's just a simple web application deployed in an application container (Payara). The web service is configured through web.xml and sun-jaxws.xml and deployed automatically. It's completely written by source code with annotations (#WebService, #WebMethod, etc) without any pre-existing WSDL file.
I need to secure it with WS-Security but I can't find how...
The most promising solution is configuring an out interceptor as this page indicates, but I don't know how to get an instance of Server or Endpoint of my deployed WS. If I use the ServerFactoryBean class, I'm creating a new Server object, but will this help me if my WS is deployed by the container?
So, how can I obtain a org.apache.cxf.endpoint.Server? Other ways of adding security to my WS?
I haven't had to build a service yet, only a consumer but you may want to take a look at the Apache CXF examples available on github under the ws_security directory.
Apache CXF Examples Page
Apache CXF GitHub Examples Repo

What is the relationship between Apache Tomcat and Apache Axis2 in the context of RESTful API and WSO2

I know I want to build a RESTful api and use Angular on client side. I am choosing between server technologies. Apache Tomcat can do RESTful web services and could do for years now. I was wondering if Axis2 is meant to be replacement for Tomcat. Also I have been encouraged to incorporate WSO2 middleware which uses Axis2. Ideally I'd like to use REST on Axis2 and then WSO2 middleware.
What is the relationship between Apache Tomcat and Apache Axis2 in the context of RESTful API and WSO2? Does Axis2 run within Tomcat?
Apache tomcat is an application server whereas Axis 2 is a Web Services engine.
So no, Axis2 is not meant to be replacement for Tomcat. An application built with Axis2 can be deployed on Tomcat or any other compatible Application Server(AS).
So yes, Axis 2 can run within Tomcat.
WSO2 is irrelevant to your question. Middleware includes Web servers, application servers, content management systems, and similar tools that support application development and delivery.
For a quick description Apache Tomcat is a web server and more precisely a servlet container that allows you to handle HTTP resquest inside servlet.
Apache Axis 2 is a librairy that can handle web services (SOAP and RESTFull), it can run on a server such as Tomcat.
For REST API you can use WSO2 ESB or WSO2 API Management...also if you want to build a restful service you can create a webapp with JAX-RS and deploy it in WSO2 Application Server. As WSO2 Application server use Apache Tomcat you donĀ“t require an Apache Tomcat Server.

In which container do JAX-RS web services run?

As of my understanding java EE application servers have mainly two types of containers. Namely web container and EJB container.
I managed to run a JAX-RS application which used Jersey as its implementation, in Tomcat. As I know Tomcat is only a web container. In order to run the web service in tomcat, the jersey jars had to be bundled into the war file because out of the box, Tomcat did not have the jersey jars. This raised me a question.
Does tomcat uses another implementation of JAX-RS other than Jersey? If Yes what is it?
if No,
I could not run the Jax-RS application without the jars bundled into the war file, this means JAX-RS apps need something more than what the web containers offer. It means they do not run in a web container. then in which container does it run?
"Does tomcat uses another implementation of JAX-RS other than Jersey?"
I don't know if you're asking if Tomcat has an implementation or if it is capable of running other implementations beside Jersey.
The answer to the former is no. Vanilla Tomcat does not support JAX-RS out the box. It is not an EE server, but simply a Servlet container. But TomEE+ (built on Tomcat) has support (using CXF).
The answer to the latter is yes. You just need to add that implementations jars and configure the app properly
"I could not run the Jax-RS application without the jars bundled into the war file"
Yup, you can't. For the simple fact there is no implementation to support the JAX-RS runtime.
"It means they do not run in a web container. then in which container does it run?"
It does run in the Servlet container. JAX-RS is actually built on top of Servlets. For Jersey, it uses the ServletContainer. Tomcat will ship off requests to the Jersey Servlet, and Jersey will process the request through configured provider and resources and spit out the response back to the container. The container will send the response to the client. (See first link below)
If you are looking for a Java EE application server, that supports the whole EE spec, you can look at Glassfish (it uses Jersey as it's implementation), JBoss/Wildfly (it uses Resteasy), TomEE+ mentioned above (uses CXF)
Here are some related reads you might find interesting:
Confusion with JAX-RS and Jersey with JAX-RS
JAX-RS specification - 2.3 Publication
Java-ee REST server with IntelliJ and Tomcat
How to use Jersey as JAX-RS implementation without web.xml?

How jetty server can be integrated with apache server?

I am developing an web application where some existing part is written already in php and for that apache server is being used. But now i have to complete rest of module in Java using jetty web server. Is there any way to integrate jetty webserver with existing apache webserver so that i can simply deploy as war file?
Yes, of course. Jetty is a servlet container similar to tomcat. There are instructions here:
http://wiki.eclipse.org/Jetty/Tutorial/Apache#Configuring_Apache

Developing Restful Web Service with JAX-WS/Axis2

I'm new with Restful Web Services and got some questions about some of the requirements needed to create one.
1) I got only Apache2 installed on machine and I can't install any EE Server. Is it possible in this circumstances create Restful Web Service? What is better in my case Axis2 or JAX-WS?
2) I want to make the content of some file accessible to Internet, so I need to create the function which is going to be called by client and return for example XML from file? Is there any way to share directly the files using URL mapping?
Thanks a lot!
1) you can't install any EE Server, OK. If you can install Apache Tomcat, use mod_jk so that Apache can redirect some requests to Tomcat. In this case you can use Apache Axis2, Apache CXF or METRO (mainly SOAP services) or Jersey (for RESTful services). On the other hand, if you can't install tomcat, try PHP with Zend Framework to develop web services;
2) with RESTful web services you can return any resource (a file content) to the user using XML or JSON.
Best regards,
Romualdo.

Categories