Axis2 POJO Web Services - java

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

Related

Is it possible to change at runtime a specific value inside a property.file in spring boot?

I'm developing an API which will connect with several endpoints. The uri for each endpoint is something like this:
rest/services/General/directory1/MapServer/export
rest/services/General/directory2/MapServer/export
rest/services/General/directory3/MapServer/export
rest/services/General/directory4/MapServer/export
and so on...
I don't know if it's possible, but would like to have something like this instead:
rest/services/General/${value}/MapServer/export
and then on my code just call the endpoint above injecting the specific directory that I want on ${value}
Is it possible? Don't know what I'm missing as I googled but couldn't find anything related.
Cheers
You can do so by means of Spring Cloud Config.
Spring Cloud Config provides server and client-side support for
externalized configuration in a distributed system. With the Config
Server you have a central place to manage external properties for
applications across all environments. The concepts on both client and
server map identically to the Spring Environment and PropertySource
abstractions, so they fit very well with Spring applications, but can
be used with any application running in any language. As an
application moves through the deployment pipeline from dev to test and
into production you can manage the configuration between those
environments and be certain that applications have everything they
need to run when they migrate. The default implementation of the
server storage backend uses git so it easily supports labelled
versions of configuration environments, as well as being accessible to
a wide range of tooling for managing the content. It is easy to add
alternative implementations and plug them in with Spring
configuration.
For more details, kindly go through spring documentation here.
I solve the problem using the simplest approach possible. In my code I used the string.replace() method. Was looking for something more robust, but as it was taking lots of time to sort it out how to do it, I decided to go with the string.replace method.

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

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.

weblogic java parameters

I have a web service which access 2 other web services. I need to deploy this web service but some how I need to change the urls from the others web wervices, later.
My question is, how can I do to pass parameters to a web service at any time. Maybe a config file, or something. In .net we have web.config, do we have this in java?
kind regards,
José Cruz
Java uses property files for runtime configuration to allow for changes after deployment. Basically it's a text file with a list of key value pairs that Java can read easily and put into a HashMap which can be accessed by the user.
http://www.exampledepot.com/egs/java.util/Props.html

How to provide access to an external resource (file) for a GlassFish web application?

I am a bit of a GlassFish beginner, so please forgive my ingnorance on the subject.
Basically we are serving a game website, and to make the client downloadable by our web app we copy it into a directory within domain1. The problem with this is that when redeploying the web app the client downloadable is lost and we have to copy it across again.
I'd like to be able to store the client downloadable in some external location and have GlassFish provide access to it.
I could just hardcode the link into the web app, but then we would lose portability so that's the reason for having GlassFish handle it.
I could also put the client downloadable into our database but that seems like poor use of a database and could also result in poor database performance.
The third option I have found is to add a custom resource mapping from some name to the file location, and then provide a method in one of my beans to retrieve the file location. This seems like a lot of work just to have an external resource, I feel like there must be an easier way.
So what should I do?
With GlassFish you can define an alternate document root to serve files from outside the war. From the documentation:
Alternate Document Roots
An alternate document root (docroot)
allows a web application to serve
requests for certain resources from
outside its own docroot, based on
whether those requests match one (or
more) of the URI patterns of the web
application's alternate docroots.
To specify an alternate docroot for a
web application or a virtual server,
use the alternatedocroot_n property,
where n is a positive integer that
allows specification of more than one.
This property can be a subelement of a
sun-web-app element in the
sun-web.xml file or a virtual server
property. For more information about
these elements, see sun-web-app in
Oracle GlassFish Server 3.0.1
Application Deployment Guide.
So you could configure something like this:
<property name="alternatedocroot_1" value="from=/ext/* dir=/path/to/ext"/>
Refer to the documentation for full details.
The link to your downloadables needn't be in the same application as the game servlets, right?
One solution would be to create a new "pseudo" application containing only a web.xml and your static file content. You would of course not deploy it in war form (well, only if you really want to) but just copy the files into the unpacked directory when you want to change content. I use a setup like this to serve a bunch of files from a Web app server I run.
At work, in an "enterprise" kind of environment, we do things differently. We have an Apache HTTPD server working as the front end. It forwards to the app server for stuff that needs to be done in Java, but any static content, as well as cookie management, SSL, load balancing and other "web server-y" stuff is done by HTTPD. This yields a bit of a performance advantage with heavily loaded sites and lots of big but static files. It also lets us split the work among different physical boxes, which again can help with performance.

BlazeDS turnkey configuration for mysql

What is the configuration and code required to use mysql within a BlazeDS turnkey environment?
You simply deploy BlazeDS on Tomcat with your application, and you may have to setup a custom channel if the default won't do (it usually is fine as it is.) Generally speaking though, you just need to be sure to create Beans that match the value object descriptors on the client side to make sure things translate properly back and forth.
This should get you started:
http://labs.adobe.com/wiki/index.php/BlazeDS:Release_Notes
I would recommend looking at the Spring BlazeDS samples - http://www.springsource.org/spring-flex It has some good examples of a full BlazeDS environment.

Categories