weblogic java parameters - java

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

Related

Create web service proxy dynamically and call its methods

I have a requirement to call 52 web services from one java project and this number will increase with time. I am using netbeans 7.3 as development tool. One way to do it is right click project and add web service reference for each service. It is not feasible because for every new web service I will have to add a new reference and redeploy the code. Also all these 52 web services will be calling each other so I will have to enter references for each web service in every other service if I go for this approach.
I hope I have explained the scenario. Now I will ask the question. If I have a url to wsdl file e.g. http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL and I know which method in this web service I need to call, is there a way to parse this wsdl dynamically to create proxy client and after that call a specific method in that web service? I have come accross javaxt API http://www.javaxt.com/javaxt-core/Web_Services which intends to do exactly the same but it is not working properly.
To sum up the question - If I have the wsdl url and I don't want to create compile time stubs but know which methods in that url take what inputs and return what values, can we do it?
The javaxt-core library should work. There was a release published 2/24 (version 1.6.0) that includes several updates to the javaxt.webservices package. More information can be found here:
http://www.javaxt.com/javaxt-core/RevisionHistory

Accessing data between jar files with two different processes

I have 4 applications in running websphere application server,one as ear file and other 3 based on message driven beansas jar files . Now i am trying to add one more application i.e jar file this application will start up on server and keep all the data in hashmap object. i want to read this hashmap object using 4th application api through one of the message driven bean code.
Is it possible to read 4th application hashmap object without RMI call?
It sounds like you want some sort of singleton service which will be utilized by the other apps on the app server. You can implement this as a #Singleton ejb, which can then be accessed by other apps using standard ejb invocation methods.

how .net MVC application can communicate with Core java desktop application using JWS?

We have a java desktop application and we are planning to launch that java desktop application using JWS and that is working absolutely fine.
The issue is -- we ask some user related information from user on web page and launch java desktop application using JWS. Now we would like to have that information provided by user on web page in our java application. Please suggest how we can access those information in java code ? We have find two approaches --
Can java code read that information from cookies ? I have not find any help how to read cookies using core java code ? again what if cookies are not enable on user's desktop ?
Can we pass information using JNLP file ? Can we write all information in JNLP file ? can pass as an argument to the java code ? does the length of the argument matter here ? can we get information from JNLP by some other way ?
Please suggest if you know another approach better then these above two approaches?
We can rule out approach 1.
Approach 2 is fine if the information is minimal. In one of our projects, we dynamically generated the jnlp file, based on information received from the web interface, which resulted in the java application being customized for the user.
You could also have the application communicate with the backend (say over http) and pull more information as required.

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.

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

Categories