JAX-WS WS-RM "from java" without manually coding WSDL - java

I have a small project publishes a web service. The wsdl is generated on the fly by the JAX-WS runtime, using annotations in my impl class.
I was hoping to simply "turn on" the Reliable Messaging aspect by flagging something. I had envisioned that I could inject some annotations in my java source and/or supplemental xml file of sorts.
Questions I have:
1) Is everything of "Metro" integrated into the JDK.
2) Does RM (Reliable Messaging) include some sort of persistent queue so that it can survive crashes and restarts without losing messages? How does the standard JDK provided JAX-WS handle this, through some sort of SQL based database storage?
3) Can I do RM without having to write WSDL files?
4) Can I use a standalone embedded Tomcat to give my application WS-RM?
5) Does anyone know of a sample that comes closest to giving an application WS-RM through an embedded Tomcat?
ps. RTFM didn't work because TFM doesn't get to the point.

Related

Configuring JBoss to create one process per http session?

In a web application I am developing, I am using a third party Java library (JPL) that uses JNI to connect to an external application: a Prolog engine.
For the nature of my problem, I need to have one Prolog engine per http session. But as far as I know the library I am using only let me work with one Prolog engine per java VM.
In order to solve this issue I came up with the idea of trying to configure JBoss to launch a new process (instead of just a new thread) per each http session, a bit like CGI where normally one process is started per http request.
In this way, certain servlets could use the required JNI based library without having to worry about synchronization issues in its side, since as I expect (and hope not be wrong about that), each of them will have an independent Prolog engine with different state (e.g., different asserted Prolog facts).
Is possible to configure JBoss (or other servlet container) in this way? Any feedback or pointer will be highly appreciated!.
To my knowledge this is not possible. However looking at the documentation http://www.swi-prolog.org/packages/jpl/java_api/high-level_interface.html#Multi-Threaded%20Queries the only problem seems to be that you can have only one open query per VM.

Integration of Java server application into Application Server like TomCat, GlassFish, etc

I am working on a server application that does the following:
Read data from a measuring device that is being addressed via a serial interface (javax.comm, RXTX) or sockets.
Exchange data (read and write) with another server application using sockets.
Insert data from (1) and (2) into a database using JDBC.
Offer the data from steps (1) to (3) to a JavaScript-based web app.
My current prototype is a stand-alone Java application and implements task (4) by writing the data to an XML file that is being delivered to the client via a web server (Apache), but I consider this to be a hack, not a clean solution.
This server application needs to start up and work also without any web clients being present.
I would like to integrate this server application into a Java application server, but I do not have much experience with these technologies and don't know where to start. I have tried some simple examples for TomCat and GlassFish, but that did not bring me any further because they are all built around serving web requests synchronously and stop where it would be getting interesting for me.
Is this possible to run such an app within TomCat or GlassFish?
If yes, where would be a good point to start (examples, which base classes, ...)?
Would it make any sense to split the application and implement only task (4) in a servlet, the rest in an ordinary application, communication via sockets, etc.?
Would other servers, e.g JBoss, be a better choice and if yes, why?
Edit:
The reasons I want to use a Java EE container are:
I would like to have a clean external interface for step (4).
On the long run, the application will need to scale to a huge number of simultaneous clients (at least several 10.000), so a want a standard way of scalability and application management.
In general, it's not a good idea to implement all of this in a servlet container such as Tomcat.
A servlet container is designed to service requests from a client. It sounds like you have a process which will be running all the time or at least periodically. You can do this in Tomcat, but it's probably easier to do it outside. Leave Tomcat to do what it's good at, servicing requests from browsers. It's happiest when the requests are short lived.
So I would do as you suggest, and only have step 4 in the container. You can easily interrogate the database populated in step 3, so there is no need to create web services to populate the servlet container.
For step 4, you will need to expose some services from Tomcat, either through rest, soap, whatever you like. The javascript clients can then interrogate these services. This is all completely doable with Tomcat.
For scalability, there shouldn't be a problem using Tomcat. If all it's doing is pumping data from the database to the client, there probably isn't a reason to choose a J2EE container. If you don't have need of complex transaction management or security, try using something open source. It sounds like you can get what you want from Tomcat (& hibernate & spring security if necessary). If you start to have performance problems, then the fix will probably be the same for JBoss & Tomcat: you need more servers.
My advice: stick to the simple open source solutions and move to an application server only if you find it to be necessary.
I would loosely couple the solution and not try to do everything on the Java EE/Servlet container as exchanging data using sockets (managed by the application itself) is not something you typically want to do from a Java EE/Servlet container.
Running this on a Java EE container might also be overkill as this doesn't sound like a typical enterprise application where stuff like security and transaction management is important and the app could benefit from services provided by the Java EE/Servlet container.

Decouple WSDL from client's app

I have a java web service client consuming web services. The client is generated using WSDL2Java tool. All works fine until the web service provider changes one of the schema objects by adding a non-required field. When the web service is called, the response is supposed to return an array of these schema objects and since the returned objects have an extra field - everything breaks. From what I understand there is a way to allow for such changes without breaking the client application.
Could you point me in the right direction on how to solve this?
Any suggestion is appreciated.
Thank you,
Nadia
Try try using different binding options for your client. If I am not wrong using JAXBRI (od JiBX) should solve the issue. try WSDL2Java -d jaxbri
The default is adb more info is in here
The web service is not conforming to the WSDL?
Maybe you can edirt the WSDL and add the non-required field
Or is the WSDL changed?
If the WSDL was changed you need to re-generate your code by WSDL2Java tool.
This problem is generally hard to solve, which is why client-facing XML schemas shouldn't change very often. You can try disabling schema validation, but if the schema changes too much, your client aplication will still blow up.
The recommended enterprisey way to do this (in the jargon: 'loose coupling') is to have a separate layer of domain objects and map between the generated Java classes and your domain objects. You just update the mappings when the schema changes, which shouldn't penetrate too far into the layers of your application. But you still need to recompile the application every time the schema changes.

Axis2 POJO Web Services

I have a POJO which is being deployed as a webservice in Axis2 - Tomcat combo. What is the best way to supply runtime configurations to the service? All servcie related config parameters are in XML file -
What's the best location to keep this config file? Note I want the service to be completely self contained.
How do I get the physical location of the service home i.e. Tomcat 6.0\webapps\axis2\WEB-INF\services\MyService?
How good is Axis2 i.e. is it a good choice to select Axis2 as webservice platform? The project is with aggressive timelines (what's new? :)) so really do not wish to dive into the Contract First etc stuff. Need a quick solution where I can drop in POJO and use it as webservice.
As always, Your help is very much appreciated!
I used JNDI to control the runtime configuration options for simple web services. How to configure JNDI depends on the container you are using, Jetty/Tomcat etc.
More complicated projects I embed spring and manage both configuration and other persistent objects.
Axis2 is a good platform for developing stand-alone web services. I'd still recommend having a look at contract first stuff. It is of course more complicated but gives more control over the XML messages exchanged between client and server. The neat thing about Axis2 is that you can start with POJOs and get more complicated later.
Note I want the service to be completely self contained.
Do u mean u would like to move this modules on other container ... which do not support TOMCAT based dir structure...... bit difficult
If Axis hosting concern is of TOMCAT alone then the best way to use the configurations is via an Property /XML file stored at the root of the Java package and haven a Startup servlet with load on startup 1 to read the property file using
context.getRealPath("") + "/WEB-INF/classes/abcd.xml" or
context.getRealPath("") + "/WEB-INF/classes/abcd.propertyfile
Store the same in a key /value based Hashtable ...further store the Hash table in Servletcontext.
On any where required fetch the Valu by passing the Key to the Hash table and use the same.
However the startup servlet should run Once only only by using Load on startup tag in web-xml ...
hope this helps

Creating a REST webserver with security

I am very new to creating webservers - and I have had several goes at trying to understand them and write a quick webserver, but it's never quite 'clicked'. At the moment I am under the impression that REST would be most suitable for my purposes (I will explain later).
Can anyone either show me a basic code example in Java (using Tomcat Apache) or a tutorial resource to show how a webserver:
Can be used for security - i.e. pass in some kind of value to identify the client - from their the webserver will either deny or grant access to the client dependant on some criteria - maybe a lookup list.
Once the client is successfully accepted they will be allowed to pass in some more values to the webserver that will be used to write a row in a database table.
Many thanks.
PS - I would have thought there might have been soemthing that comes with Eclipse Ganymede? If someone can confirm?
The best way to write restful resources in Java is via the JAX-RS standard. So I'd recommend you download Jersey which is the JAX-RS reference implementation and check out its examples; its got lots of them. Take an example for a spin then try hacking it to do what you like.
BTW JAX-RS can be run inside any Servlet engine - you just build a WAR and deploy it (there are examples in the Jersery samples) - though Jersey also comes with a small lightweight web server you can use too which is a little easier to use - again there are examples in the distro of this.
I would also suggest that you look at Restlet

Categories