Best way to deploy a web site alongside an axis2 web service via Tomcat? - web-services

I am using Axis2 (1.5.3 currently) and Tomcat (6.0.26 currently) and am running a web service. I would like to also host HTML pages for configuring the web service.
What is the best way to go about this? I assume keeping the same context is key, but perhaps it is not.
My current distribution is located under a folder structure similar to this:
Tomcat/webapps/mycompany
With the actual service code here:
Tomcat/webapps/mycompany/WEB-INF/services/myService
In a browser, I can hit my web service by going to here:
/mycompany/services/myService
I note that I can drop actual HTML files in this path and Tomcat will, indeed serve them up.
For instance, if I put "index.html" under Tomcat/webapps/mycompany, I can navigate to /mycompany/index.html and see my html.
What I want to do is have this HTML be attached to JAR/class files that can interact with the already-existing service class files in the same context as the service. Therefore, I can have the browser configure the web service directly.
Is this possible, and is there a tutorial or something out there that will help me with this? Note that I have been working with Tomcat and Axis2 for a while now for this particular web service, but I have never actually deployed a web application/html using Tomcat before.
Thanks.

First of all what do you mean by a configuring a service. Normally in SOA world services are analogous to interfaces. IMHO you can just change a service, since their are other users that rely on the services you are exposing.
If i want to change a service i would rather introduce a new version of the service after deprecating the existing one.
Are you talking about applying QoS to existing serviecs. Then that makes sense.
Anyway, If you want to have a web-app alongside with axis2 service engine, it is possible. If you look inside the axis2 war file you'll find the web.xml entry to Axis2Servlet. It is this servlet that serves the web services requests.
So, what you need is the Axis2Servlet mapping in your web-app along with your usual servlet-mappings. Number of possible ways to configure your services using web-app files. One options is to use web-services call itself to (with authentication) to configure it.

By "configure a service", take this example:
The service has a set of datasets.
Each dataset exists in a separate database.
The service can manage 0..n datasets.
The service must be configured to know about each dataset.
This is what I'm configuring. I'm not trying to configure Axis itself or redefine the service.
I would like to host the HTML using the same instance of Tomcat that I'm hosting the web service with. It needs to manage sessions, have login capability, an whatnot, and has to be able to configure the web service live.
From what I'm reading, it's probably best to make an interface to the web service that the web application module can call into from a different context.
Is there a better way?

Related

Do I need a web service in this case? When do we use them?

my issue is about web services and all the stuff around that. I've developed a java web app, using hibernate (to connect with a mysql DB), jsf and primefaces. The only thing I have to show to the user is the index.xhtml which will search a data in a database. All of this is running on my PC with my local apache server.
But a doubt comes to my mind when I wonder if I deploy this web app in the apache server of the company, do we need something such as a web service o something like that o they just can access to the index.xhtml and start the queries?
Sorry for this but I'm totally new repesct web services, web app, web server and all these stuff.
PS. So, when do we use web services? and web server?
Thanks in advance :)
A web service is typically used as an API that might be integrated into another application. For example, if you have a way to accept payment information. You could make that a web service that would let some other application (e.g. an auction site) make calls into your web service to do some work.
Think of it a bit like a DLL that is accessible on the web. It won't have an interface, it is a collection of methods that either return data or execute some code. It will not return a UI.
So when you use a web service would be a similar question to when you need to break code out into a separate assembly.
On your specific question above, you would not need a web service, if your web application is doing everything you need it to do, then all you need is a web application.

How do you put IIS web services into maintenance mode?

How do you put web services into maintenance mode?
I've tried the app_offline.htm, doesn't seem to work well for web services. Does work for web site though.
app_offline.htm worked fine for web sites, but not for web service. When I called an web service function via code that's supposedly under maintenance (put the app_offline.htm under the root directory of the IIS web service), I still got the proper response as usual.
Ideally I would like the web service that's under maintenance to return to me a message like "under maintenance".
You can edit your Global.asax as suggested by this answer to another question. Then trigger it by setting a flag when you are in maintenance mode
In my opinion, when a service is unavailable, you should respond with a 503 Service Unavailable status; but you can do anything you like with the response.
Create a utility function for your web services, which checks for the presence of app_offline.htm at your website's root path, and responds accordingly.
Note that if you wanted to get fancy with it, you could use a part of the WCF pipeline (assuming you're using WCF and not the legacy .ASMX services) to modify your services/methods by using an attribute (eg, this method).

how to publish and discover a java web service

I am new to developing web services using java. I have an academic project where I need to do dynamic service composition. For that I can't directly create a service-client for a particular service because if I do so then that client will call that particular service only. Client need to search various web services and then out of those services select any one at run time and also call that service at run time.
I was able to develop the web service(JAX-WS) using Eclipse(indigo), I also created the client for that web service and every thing is working fine. Now my problem is that while creating the client I am hard coding the client to call that particular web service only(since I am creating the client using the WSDL file of the service). However I actually need to call any one of the searched service, but for that I need to publish the service some where then discover it and then call it.
I tried publishing the service to juddiv3. But on juddiv3 I could only publish the sample service supplied with the juddiv3. When I try to publish service created by me then it is not getting displayed in the group of published services.
Is there any other UDDI server which I could install on my local machine and then publish and discover the service from that. Also I was not able to figure out how to create a client that will modify itself at run time to call any one service out of various searched services.
Kindly provide the necessary steps and code.
Thanks
You can use jUDDI (http://juddi.apache.org/ ).
juddi is based on UDDI v2.0, v 3.0 .
Here, you can publish as well as discover your web service.
For integration, you have to make some application which integrates with jUDDI.
But I think for your academic project, and for your purpose, jUDDI is best suitable! ( :) )
jUDDI has a boat load of examples in the source code trunk. You may want to check them out. It's difficult to guess what the problem is from the little information you've provided. Consider contacting the jUDDI team for further assistance. http://svn.apache.org/repos/asf/juddi/trunk/juddi-examples/. There's also additional document for working with UDDI in the jUDDI user's guide, which is at the jUDDI web site
You cannot directly publish on jUDDI. You need to create publisher entities in jUDDI server also. You'll find Rename4Sales and Rename4Marketing examples in 'Classes' folder in the standalone server's juddi application. Use these XMLs as your basis and create your own entity. You also need to configure the server's login credentials.
I suggest you follow the tutorials on jUDDI blog.

Does A Web Service Have To Be Registered?

I'm learning about web services and most of the resources I've been reading talk about registering your web service once it's ready for use by others. Is registering a web service required to use the service?
For example, let's say I have a web application on a company intranet and I create another web service app that retrieves some sort of useful information to be displayed on this private intranet site. Would this new web service require being registered just so my web app can use it or can the web app simply interface directly to the new web service (following the WSDL file) without the need of some sort of UDDI registry?
You can certainly use the service without the UDDI registry.
I have created several Web Services and have immediately used them without registering them. Registration gives others confidence that your Web Service is legitimate and descriptions of how to interact with those services.
Imagine doing development where you have to register any Web Service before using it. Yikes!
No, not at all.
You are probably talking about API directories you may register your WS at. Like UDDI or what it’s named. Entirely optional.
Nobody uses UDDI anymore. It's an idea whose time has come and gone.
It was thought that there would be public registries of web services that everyone would use to find a web service to meet their needs. That never happened.
How could either the service or the app know whether or not the service was registered?
Furthermore, why would they care?
If you're trying to use service orientation the right way, your web services should be registered within a service registry. The registry should contain the published contract of the services and any meta-data that helps the discovery process.
A different questions is: does a service consumer program need to look up a registry and dynamically bind the service it needs to call? NO, NOT AT ALL.
But then, what discovery process am I talking about?
I'm referring to a human (developer, architect, etc.) who is designing/developing a program that needs to call a service. This person should have means to search what services are available in his/her organization. If not, the benefit of reusing services is compromised.
Discovery is also about humans finding out there's a service somewhere in the IT organization that offers the functionality they want.
In this case, the registry can be as simple as an html report that is created and updated manually or generated by parsing (xslt comes handy) the wsdl files.

Problems calling a web service from another web service with netbeans and jax-ws

I want to expose a web service on one node that defers onto the same web service contract on another node, basically then, proxy the web service, both nodes running glassfish.
I am using netbeans and jax-ws and I cannot get it to work. I generate the web service server part and the web service client part and use the same dto's. So the service method is very simple, just passes the request on.
My current problem is that it is insiting on using ws-coordination to "coordinate" and this uses ssl to connect between the servers and I haven't configured this so it fails.
using Glassfish 2.1 and netbeans 6.7
Has anyone successfully done this? Does anyone know how to disable ws-coordination? I'd rather not use ws-coordination as I definitely don't need it and don't want to have to configure ssl.
I've done something similar using (AsyncProvider)-based Web services.
However, you might need to write your own TubelineAssembler to create a tubeline without the Tube that processes the ws-coordination related elements. An example of how to create your own TubelineAssembler can be found here.