Java web service call from RDz - java

I don't know how familiar anyone is with RDz, but if you know IBM mainframe stuff and how webservices work, then maybe you can help me.
My MF has a UNIX side, and a CICS side, and I need to put a java appplication on the UNIX side that can be called from CICS in which invokes a web service from the java program on the unix side, then returns some data.
Anyway, I have everything else working, but I need to know how to invoke a webservice with data that is being passed to me through a CommArea CAH parm. I am kind of a newb to webservice, but it's always nice to learn.
EDIT: This java program needs to be independent and be able to run on its own without any manual operation.

Invoking a web service from a CICS application is done via the INVOKE SERVICE CICS API.
In order for this to work, you begin with the WSDL for the web service you wish to invoke. You run the WSDL through an IBM-supplied program DFHWS2LS (DFH is the IBM abbreviation for all things CICS, WS2LS means Web Service to Language Structure). DFHWS2LS is part of what IBM calls the Web Services Assistant.
Out of DFHWS2LS you will get a web services binding (WSBIND) file and language structures. The language structures you include in your program and move the data from the commarea into them. The WSBIND file you provide to your CICS Systems Programmer so they can include it in the pickup directory for your pipeline. You must also create a pipeline configuration file.
All of which is to say you have asked a very large question. :) There are multi-day courses and books on this subject.

Related

Web Client API and Rest API

As I have understood we use Web services(Rest/Soap) so that a piece of code with some functionality written in one language(say Java) can be used by other programmer no matter the language(say Python) he is developing the application over the internet.
One of the projects I came across uses EWS web services to create,delete appointments on our Outlook 365. The application is developed in Java and a JAVA EWSAPI.jar file is included in the library path(which contains class files like appointment.class,Meeting.class etc) to connect to EWS server and create meetings .
My confusion is suppose we were developing the application in Python, so for that do we have another API (say EWSPython.pythonextension). So then how developing a web service helped us.
I understand API defines the set the methods available and how can they be called with argument.
Please clear my doubts.
I think that you have misunderstood the aim of webservices. We need webservices to make their calls (clients) a platform independent interface which means that once you have created your webservice using any technology (java for your case here) now anyone can call this service by creating a client using any language like python, C#, C++, Ruby, ........... in that case a service which was built by Java will be consumed or called by an application or client created using python and vice versa.
JAVA EWSAPI.jar file is a API Client Library.
What is a client library?
A client library, sometimes called a helper library, is a set of code that application developers can add to their development projects. It provides chunks of code that do the basic things an application needs to do in order to interact with the API. For example, a client library may:
Provide boiler-plate code needed to create an HTTP request and to process the HTTP response from the API.
Include classes that correspond with the elements or data types that the API expects. For example, a Java client library can return native Java objects in the response from the API.
Handle user authentication and authorisation.
How is that useful?
Looking at the developer who’s using the API: With a REST API or any web service API, the developer could be using any of a number of programming languages to make the API calls.
Wouldn’t it be great if we could give them some code in their own language, to help them get started with the API? That’s what a client library does. It helps to reduce the amount of code the application developers have to write, and ensures they’re using the API in the best supported manner.
For more information:
https://ffeathers.wordpress.com/2015/10/25/what-is-an-api-client-library/

What is the best way to create a client-server application with a Java Web Start program?

Ok so I have created an application, which is a Java Web Start application, but I have determined that I will need to write data to the server machine, hence the need for an additional server application. Pretty much I want the client to send different strings in order to process a clients requests in varying ways (eg create a new user file on the server machine or send user data read from a file to the client machine).
I was thinking of possibly using sockets, but if there is a better way then I'm all for that. Also I assume that whatever I do use, I will need to use threading in order to process many simultaneous requests, is this correct?
For your purpose you better create a webservice which communicates over http for exchanging data. I would recommend doing this in Java or maybe creating a WCF in C#.
Tutorials in Eclipse for java webservice: http://www.vogella.com/articles/REST/article.html#first_project
In netbeans: http://netbeans.org/kb/docs/websvc/jax-ws.html
The first tutorial is a restful service which is pretty popular and easy to grasp.
Good luck!

Simple web services in Java applications

I am new to web service and WSDL. I have a MySQL database stored in a server and I need to create a very simple web service that allows third party Java applications to input an integer (say 'membership number') and receive a string (say 'member name'). This should be done with WSDL.
Can someone please tell me what files do I need? A WSDL file, a schema file? Do I need a Java class stored in the server responsible to communicate with the database?
I am pretty lost, I would be thankful if you could give me some suggestion
As the simplest form of webservice is you can continue with JAX-WS, upon deployment of appilication it will publish a WSDL file and you can use this WSDL to communicate it from client
JAX-WS is the simplest way to convert an existing method into a web service endpoint, with a few annotations, and the simple web server in the standard Java 6 JRE. It can autogenerate the WSDL too.
This tutorial covers the essentials for getting started: http://java.dzone.com/articles/jax-ws-hello-world
I have found this to be a very robust technology.
Using the SOAP Webservices can get pretty messy. Unless you are forced, I would recommend you use REST for webservices, it is much less complex than SOAP. You can find a good REST tutorial here.
If on the other hand you must use SOAP, you could strat by taking a look here.

Exposing C++ program as a Web Service

How to expose a C++ program as a Web Service?
Or is it a better idea to invoke C++ from Java and expose the resultant Java as a Web Service.
In any case, the C++ program should not undergo any changes.
Consume C++ program in Java WebService end point and expose java webservice
Use JNI to consume C++ program
Nice article from JavaWorld
Interestingly, webservices work on http protocol, which means that you can't "host" a webservice written in C++ without having an http server. Since each web server will have it's own mechanism of writing "hooks" or extensions, the next obvious question is which web server would you like to chose.
Let's say you want IIS on Windows. It's possible to use ISAPI extensions; so you need to know how to write one, which complies with web services standards. Or, alternatively, it's better to learn how to do it in C++ with Visual Studio, which will have lots of built-in stuff to help you get started.
In short, there is no "standard" way of exposing a web service in C++ and you have to be "platform" specific. Windows with IIS has one way of doing it. Apache Axis C++ has another.
You can try c-sevice-interface https://github.com/Taymindis/c-service-interface.
It create a C/C++ program as a service port and listening to NGINX fcgi.
This is a small bridge engine which can handle high load of request, any segfault will not break the engine, it will catch and free the thread, it is built on top NGINX, FCGI. You can setup the proxy, load balance, authentication via NGINX before reach to your interface.
The link shown as below is a wiki to Guide you how to startup from scratch.
https://github.com/Taymindis/backcurl/wiki/How-to-build-BackCurl-for-cpp-Android-development

Communication between two Web Services

I have a problem with web services. They are programed in Java and are running on a WASCE server ( both are on the same server).
My problem that i want to solve:
We have two Web services: App1 and App2
In App1 i want to call a function that is in App2. How can i do this? Is this even possible?
I tried creating a soapClient inside the App1 so i can connect to the App2 but that doesn't work.
exp:
I have a client that calls app1 gets data from app1 and send it to app2 then get back the response data from app2 and send it to an other function into the app1.
What i want to do is to skip the client part and do it directly so that app1 can send directly the data to the app2 and then receive an answer do whatever it needs to do.
For the note: Both of the web services use the connection to the database.
Thank you in advance.
(it has been edited with additional data)
What does "doesn't work" mean? Exactly what happens?
Start by generating some client code for App2. Can you use that from some simple Java environment, or say a Servlet. If that works, what happens when you try to call it from inside your App 1 Service implementation code?
However: if these are related services running in the same JVM can you not set up some simpler relationship using java libraries. My preferred way of developing a service is first to develop some useful Java code, and make sure that works, then "wrap" it as a Web Service. In which case I have a callable routine that can just be invoked as Java.
It's definitely possible, with differing levels of complexity and feasibility depending on exactly what it is you want, and the restrictions you place on it.
Probably one of the simplest ways to go about this, if you don't have a problem with the method in App2 being public, is to simply create a web service exposing that method and call if from App1.
If you want App2's method to be essentially "protected", so that it can be called by App1 but not by public clients, then there are several alternative options. Firstly, you could use firewalls or equivalent to prevent external requests to the service URL. Alternatively, you could expose the method through some form of interprocess communication; RMI would be the obvious native one for Java (set up an RMI method in App2 and export this through a manager, then obtain the reference in App1 and invoke the method remotely). Depending on exactly what it is you want to do, you may be better off with a framework that does all this under the covers; e.g. distributed objects through something like Terracotta.
You should give more detail in your question, though - currently the only thing you've really specified is that you want to call "a function" in App2 from App1. There are dozens (if not hundreds) of ways to go about this and the best one(s) will depend on the details of what you're trying to do.
EDIT (in light of comments): It's not the details of what you want to do that are lacking - I understand fine that you want to call some method in App2 from within App1. It's more the architectural details - what languages are both clients coded in, what libraries are you using to do the web services, are both clients on the same machine or separate ones (and if same machine, same JVM or not), are there any firewall issues that could inhibit certain kinds of connectivity, are there any office-political restrictions that could inhibit your options, are there any security restrictions that could do the same (such as whether you can expose the functionality of App2's method publically or not). All of these will shape what is possible and what is optimal - because at the end of the day, all networking is basically I want to use resources on that remote computer from here. Without more architectural specifics, there are literally dozens of ways that you could achieve this.
Regarding exposition: You would create a web service to expose App2's function in the same way you would create any other web service (with the details being dependent on the tool/framework you're using). As an example if you're using a tool that supports the JSR-181 annotations, you'd write a method in App2 that performs this function, and annotate it with #WebMethod. Then you'd ensure that if this method is not part of an existing webservice class you'd annotate its class with #WebService. I was presuming that since you already have a couple of web services, you'd know how to write/define them.
As for accessing the web service from App1, this can be done quite simply by a Java SOAP client. A tool such as WSDL2Java can create a stub class modelling the remote service that you can call; alternatively you can get a richer interface with something like CXF.
What WS library are you using currently, and what errors have you encountered when trying to use it to perform this interaction?

Categories