Is there a way to stop auto publish of a JAXWS webservice? - web-services

This is with respect to a JAXWS webservice. In a library (jar), besides many other classes, I have all the classes generated by wsimport, and the implementation class.
Two separate (EAR) applications depend on this library for different reasons.
In one application, I would like the webservice to be not started (not available), in the other application I would like the webservice to be up and running.
I did not write any Java code explicitly to start the webservice. I think, since the implementation class has #WebService annotation, and so, the environment automatically makes the webservice available.
If instead there is a way to manually start (publish) the webservice, and not use the automatic means, then we can do the manual publishing/starting in one of the application where it is desired.
Any ideas?

Related

Calling c++ in web-services

In my mind a webservice is a service that create a link between some applications. What I want to do is calling a c++ program installed on a server into a webservice.
However I have found how to call a webservice in a c++ program but that's not what I am looking for.
How do you call a c++ code into a webservice ( I am using VS2013 btw) and is it relevant to do that.
So my question is : How do you call a c++ code into a webservice ( I am using VS2013 btw) and is it relevant to do that.
A web service is a service accessible remotely, which publishes several "endpoints".
Each endpoint corresponds to a function call (possibly implemented in C++).
To call a webservice endpoint, you must serialize the input parameters of the endpoint in a format accepted by the web service (in practice, this usually means generating a SOAP/XML document that contains the values of the parameters), then sending the serialized document to the server. The server then de-serializes the parameters, calls the function, serializes the result, and sends it as a response.
Webservices publish their endpoints (their accessible/callable APIs) in another XML standard, called WSDL, and public web services are usually listed in a public directory.
For this you will need a networking library usable in C++ (see gSoap), or an implementation of your own, on top of a networking library (see boost::asio).
It depends on in which language your web service is coded.
If it is PHP, see the function system to run another programme that you can code in any language you want (including C++ then).
If it is C/C++ on Linux, see the functions fork/exec's to create a new process and run another programme in that new process.
If it is C#, see this tutorial on Process.Start.
If it is Python, see the subprocess package from the standard library.
Anyway, if your web service is in C++ and that the code you want to execute is in the same programme, you can just do a function call in your web service's method.

Invoking servlet from Java GUI application?

I know that similar questions have been asked before, but I would like to know if you can actually call a Servlet to do some work made on an EJB module, and then return the data to the standalone Java GUI application.
The requirement of the project says that both a standalone Java GUI client application, and a web client application should access a Servet to do their work, that is update and retrieve data from a database.
Does it make sense to use servlet for the GUI client to access the EJB, or why not access the EJB directly from the stand alone GUI application without invoking the Servlet at all.
Yes, you could call a servlet which in turn calls an EJB.
But you can call an EJB directly from a stand-alone application as well. If your servlet returns HTML markup (content type "text/html" - for human beings), you will have to parse it (requires effort) to get the same result. Every time the markup changes, your client has to be changed as well.
Even if there is a firewall in between (= direct RMI is not possible), you can use "RMI over http(s)", and there is a HTTP based naming service as well (JBoss offers this functionality).
On the other hand, if you mean a servlet which implements a web service which returns XML or JSON, it's a valid approach, especially if clients from other languages (C++ for example) are involved. Another advantage is that you can read the result using a browser (no need for a special RMI client). In that case have a look at available tutorials to implement a webservice in Java

Spring bean as Web Service

Am new to web services. I have a spring bean in which i have used Transactional annotation for DB operations.
Now I need to expose one of the method in the bean as a service.
The method parameters are Hashmap and a POJO (like JPA entity) object. return type is HashMap.
What is the best way to implement it.
Directly exposing the bean using Axis2.
Using Spring-Ws with CXF.
Writing a new method in a new wrapper class which accepts Strings as parameters.
(These string are actually as required by the original Map and POJO ).
And by setting these strings as properties and objects in POJO and Map respectively, as required by original method.
The Third method wont work in my case as the Map will contains several arraylists which needs to be stored in DB.So I have to use Map only.
Shall I go with SOAP or RESt.
Already two web services were provided using Axis2 in our project by old team.
We are using spring 3 (as core container and for ORM), Hibernate template, Tomcat 6.
Well, that question is best answered by yourself. We can only give hints here which framework and technology might work out best for you. In order to give any hint, we'd need some more information about your project.
SOAP and REST, for example, are two essentially different technologies. The SOAP protocol must use XML as information medium and can use literally any transport medium, e.g. HTTP, E-Mail, JMS, etc. Using SOAP, the contract, which is the WSDL specification, between a service endpoint and a client is the interface description. The REST protocol can use any information medium, e.g. JSON, XML, YAML, etc., but is limited to the HTTP protocol as transport medium. Here, the HTTP methods like DELETE, GET, POST are the interface description.
You said, you're actually using AXIS2. If your experiences with that framework are good enough, I would recommend to use it further. CXF is simply another Web Service Framework which cannot be used together with Spring-WS (but it can be used with the Spring Framework). Here, I would consider that each framework has its caveats and needs some time to learn.

Is there any problems when using Delphi to create Web-Service client?

I plan to start developing web-service client using Delphi XE. It looks like creating web-service client on delphi is easy to do.
Is there any bugs or problems when creating WebService on Delphi XE?
Is there any problems with other versions of Delphi (not XE) ?
(To create web-service i plan using WSDL-importer dialog)
Please, place Delphi version, you used to create web-service in answer.
I have created several webservice-clients in Delphi, all by using the wsdl. I have not encountered any problems so far. I have encountered some small problems, but nothin that couldn't be resolved with Google or Stackoverflow :-)
It depends. To answer your last question first, later versions of Delphi are better at generating a Web service client than earlier versions.
As for your first question. I have also created a number of Web service clients (and servers) using various versions of Delphi (most recently, Delphi 2007 and Delphi XE, though I also used Delphi 6, Delphi 7, and Delphi 2005). When the Web service methods use simple data types in its method parameters and return values (strings and integers), Delphi often does a good job of generating the client code using the WSDL importer. When complex data types are involved (objects, for example), it might be more challanging. For example, if the Web service uses complex types, and the WSDL is the only source of information about those types (you did not create the Web service, there is no documentation, or you cannot get the source code to it), it might take more work. It really depends on how complex the complex type is.
Additionally, if the Web service employs additional features such as authentication or other specialized headers, you will have to manually modify the code created by the WSDL importer. However, as birger noted, most of these issues can be resolved with research.
On the other hand, if the Web service was created in Delphi, it is usually very easy to create the Web service client.

Can WSDL 2.0 (or similar) be used to generate a web service boilerplate?

I apologize if if this is a bonehead question.
I've used WSDL to generate code to talk to web services, but my question is about using it to actually generate web services.
Let's say that I have a device that is going to communicate with a web service. The web service in question doesn't actually exist and is out of my control. That is, the party wishing to process messages from my device must implement the service.
The service in this case is extremely basic. It's simply a small collection of methods that receive messages and return status codes. It's basically a middleman between my device and 3rd party software.
It would be really cool if I could supply something like a WSDL 2.0 document that they could then use to actually generate the boilerplate code for the service and methods they are required to implement...preferably in Java (Axis) and .NET friendly frameworks.
In other words, I want to use WSDL to generate the service, not the client. Or maybe I don't want WSDL at all. What techniques would you recommend to make this as painless as possible?
SvcUtil.exe for the Windows Communication Foundation technology in .NET 3.0+ can do some of what you're asking, i.e. generation of contract interfaces and basic client code using a predetermined WSDL as input.
Now, this will not fully generate the actual service, just the contract interface. I don't know of an easy way to do this as it is probably not a very common case. Essentially what you're asking is a slightly more automated version of what Visual Studio does when you create a class and use the "Implement interface" feature (which I believe is accomplished mostly through VS templates).