Use utility class in web application or web service? - java

I know how to make web application in technologies like jsp/servlets and applications servers.
Suppose I make some utility method for particular application say ‘A’ and its working fine no any other web or desktop application in need of this method.
Same thing I can provide such utility method via web service like Rest/Soap.
So why I need web service in this scenario, I can imagine if such service is useful for other application and we provide it as web service then its fine.
Can anyone give me some answer which clear my doubt?
Thanks

Based on Your Comment, i would like to clarify.
Web service is a concept in which you expose a utility or functionality to the world.
Any one in the world can access the same by first establishing ground rules as in SOAP via WSDL.
The Services can serve any number of requests from any application provided it sends the proper input request needed by your service.
In case you have built an application A with a utility functionality X,
Then application B,C,D and so on can access the Web Service.
All it needs is:
the URL for the Service which is exposed through network to the consuming application
The requested parameter format
and the Proper Response format.
Once this is setup, any application, not just in java, can access the service so even .Net applications or PL/SQL applications can access the Web Service Utility.

Related

Converting methods to web services in JAVA

I am currently reworking a legacy JAVA data driven web application to a MVC model. While reworking, I realized that almost all servlets call a getID() method and almost 10 other methods. I am thinking of converting these method calls to a service. This would be my first web service development. I use Eclipse and weblogic. While I am reading up online, can someone give me a brief outline of how this can be achieved to get a head start? Another question is, do these services get invoked from a business class or a servlet or a jsp or from all of these? Thanks.
Web service can mean XML-RCP, SOAP, or REST. To me, web service means "calling a networked component via HTTP." If you agree, you can simply refactor those methods into another servlet and call it a service.
Don't use XML request/response unless you need to.
I would not invoke services from business classes. Servlets and JSPs are firmly in the web tier, so I can both calling a web service (e.g. AJAX calls from a page).
But my preference would be to have a true service layer, with services calling services. The service layer is more reusable than it'll be if you embed that stuff in the web tier. What happens to all that code if you go with a mobile UI? The web tier should validate and bind input parameters, call services to fulfill the use case, and package up the response for display. Let the services do the heavy lifting.

Client architecture for calling Spring based web service

I have written a SOAP based web service which runs fine on a Tomcat server. The Web Service service itself is a Spring MVC based web service that runs on the Tomcat application server.
Now i need to write a Thick client which will be a standalone Java app that will use the services of the web service. I think i am correct in that the client only needs to know about the service details (i.e. operations) and nothing else.
What i am not sure of is the architecture and environment i should use for the client. The client application will be based on Swing but is it possible to use Spring with Swing together?
On the web service i have the following setup
view --> Service --> Model
The client application is basically a configuration tool. It uses the web service to configure user accounts. This means that the client application does not actually write anything to any database. It just uses the services of the web service to make changes to 'user account' and probably view list of accounts.
My question really is
- Is an MVC design suitable for such a use case
- Usually Spring is used for web based applications. Is there any benefit in using Spring with the Swing based client?
- Are there any alternative or better solutions/design/architecture that would achieve the same?
An example showing Spring used in conjunction with a Swing application would be very usefull.
Thanks in advance.
Spring MVC is not appropriate for a Swing-based client. Use the core Spring framework and a JAX-RS implementation like Jersey to provide simple REST web services in tomcat. Jersey also provides a corresponding client API that you can use within your Swing application to invoke the REST services.
If you have decided upon Swing as your platform, there are two options you can look at:
(1) Net Beans Rich Client Platform
http://netbeans.org/kb/trails/platform.html
(2) You can roll up your sleeves and write your own app using a low level yet extremely flexible framework called Swixml
http://www.swixml.org/
Give Swixml a good try before you try others, it may surprise you.
You can implement Swing-based thin client application with Spring Integration backend serving as a integration tier. It can expose gateways accepting simple Java types or DTOs. Your Swing presenters / controllers interacts with these components in order to call remote webservices.

Webmethods - Can it host its own web services?

Webmethods Integration Server can integrate systems and orchestrate different web services from external systems on the network.
My question is: Is it possible to create Java code running in Webmethods Integration Server, and expose it as a web service? Therefore, having Webmethods host the web service.
yes that's possible. You can use a Java service inside IS to code your logic. You have to define an interface for this service (a doctype). After this is done, you create a webservice provider that calls your service.
This applies to IS from version 7 upwards.
Absolutely, that's one of the core purposes of the platform.
To expose any service (flow, java, adapter service etc) you need to create a web service connector (of type "Provider") and then drag the services you want to expose onto it. You can then point to the WSDL it generates.
The approach of webMethods to have everything as a service means that any code you write on the Integration Server can be added to one of these providers and thus invoked as a web service.
You can also proxy other web services (e.g. the wrap and layer approach) by building a web service connector (Provider) using an existing WSDL. What it will then do is mimic the existing WSDL and allow you to provide an implementation of it.

Generate SOAP Web Service client forms (Java)

I have a Web Service accessible via SOAP. Let's assume it provides a method with the signature
sayHello(String name)
Of course, I have the WSDL describing the Web Service.
What I want to do now is to generate a client web application (war archive) with a GUI that provides a form to enter the parameter for the Web Service method. In case of the example, the form must just allow to enter the value for the "name" parameter. Then, a SOAP message must be assembled and sent to the WS.
Is there any way or any framework to generate such a webapp automatically!? The actual kind of the resulting webapp is not important, it may be a GWT webapp, JSF, plain Servlet with JSP or whatever. Even a plain HTML/JavaScript client app would be OK.
I mean, there are tools to generate CRUD forms out of data models, so there must be tools to create forms for Web Services, too...
I've been googling around for a long time, but the only thing I've found is a feature of Eclipse: http://www.eclipse.org/webtools/jst/components/ws/M3/tutorials/WebServiceClient.html . Basically, this does what I want, but I'm looking for a more ..hm.. elegant way to do this ;-)
Thanks in advance,
Frank
What you are looking for is (I think) similar to what this site seems to do: link soaptest
As far as I know there is no framework that supports this out of the box.
All frameworks support the automatic generation of client stubs and artifacts and application developers use that to implement their functionality.
In your case create the HTML interface your self to test the web service.
Only .NET web services provide similar tool for testing link text
If I remember correctly, Netbeans provides simple web pages to test the functionality of web services methods (methods offered by the server). You can find a decent amount of guides showing you how to create wevservice clients on youtube. It is a relatively straight forward process.
If it is just for testing the web service: go for soapUI. It's a standalone application and (to my opinion) a must for every SOAP engineer.

Translating SOAP Web services calls into JMX API

I have SOAP web services for Application 1 available to me. And, I'd like to implement a Java application that translate Application 1's Web Services calls to Application 2's JMX API. So App 1 can manage a bunch of operations through App 2.
If I understand the problem correctly, I want to build a SOAP/JMX Proxy (Remote Proxy design pattern) as my translation layer. This means it will receive SOAP requests and translate them to JMX, forwarding the translated request and then do the inverse to return the response.
Do you have suggestions on this approach and if there is another way to proceed? Any pointers/corrections are highly appreciated.
Epitaph, this looks like a repost of your same question Ideas on how to approach a project involving Integration of APIs. In essence, it is the proxy pattern. Your web services are just calling another object via the JMX API.

Categories

Resources