How to send an HTTP Post to a URL from a VG-IDMS - http

Does someone knows a way of sending an HTTP post to a URL from a VG-IDMS program?
We have a mainframe database with a few programs written on it and we have so far successfully created functionality for it to work as a kinda web service provider, responding to HTTP get requests with XML data. That way we've been able to create external (and modernized) apps that requests data from it as if would be a modern server.
Now we'd like to make the opposite. We want certain VG programs to create and send HTTP post requests to an external URL (most likely JSON formatted although not important). The objective is to create some sort of notification so that when certain events happen on the mainframe (say data got updated) a VG program would notify an external web service (or web api) of it.
I've been trying to find documentation all over but failed so far.
EDIT: Replacing the old mainframe is not an option for now

Related

Handle external API calls inside an api

I have a simple HTTP server where you can create and manage todos. You can also add plugins in order to, for example, send an email to the people who starred a todo when that todo has been completed. I currently check for all enabled plugins through an query to the database, and then query each API endpoint for the different plugins (Gmail, Notion, Trello, etc). After this is finished, I send a response back to the user. This is a problem, because it means I rely on the speed of the external API's I am requesting for my response. If the Notion api is slow, then my endpoint is also slow.
Is there a way to first send a response after, for example, the server marks the todo as completed, but then send a different response after all the plugins have been queried (Gmail, Notion, Trello, etc)? Would I have to use web sockets? Or is the way I currently handle external API queries the only way to do it?
You are right thinking that you want to decouple requests from customers with backend processing (reaching out other providers); and web sockets is one of options to do that. HTTP2 streams is another options. And, of course, pulling is also a way (simple, but not too efficient).

How to create multiple devices automatically in Thingsboard and post telemetry data using HTTP Api

I'm using ThingsBoard to publish some data and I want to create multiple devices automatically using thingsBoard Rest client API and send JSON data (stored in a JSON file) to each one of them, I’m also writing a JAVA program to so but I was using only one device to send the data by copying the Access Token of the device so it can receive the data, however I don’t know how to do that if I have many devices to get the Access token automatically from each device.
I’ve been trying for a while to look for a simple method to do so but I’m a bit lost here.
Does anyone have an idea how can I do that.
Have a look at the ThingsBoard administration API described in this swagger https://cloud.thingsboard.io/swagger-ui.html
A few end-points will help you achieve what you need:
for devices already created manually, you can retrieve their credentials using
GET /api/device/{deviceId}/credentials
for devices without credentials, you can create some using
POST /api/device/credentials
Since you're working in the context of a Java application, I assume you already have a REST client with authentication to perform these calls.
What you can do is use GET /api/tenant/assets?type=telemetry&pageSize=10000&page=0
This will get all the devices of type telemetry, and then you can fetch the part where the token is. That request will return a list.

Webservers and POST requests

I am a beginner in handling web servers. I have a requirement where I would like to publish files into a particular location on a node as well as display the content on a web UI. Lets say these files are present on another node. How can i send these files from one node to another over HTTP? Do i need to have a web-server running on the destination node? And if that exists, can i send the files by using the HTTP POST option? Will the web server be capable of extracting the data from the request and writing it into the file system of the destination node. I just need an outline of how this works. What are the tools that are needed to set this up. I am not sure how to search for it in Google so having it as a question. There could be a million ways of doing this but my objective is to learn about the HTTP POST and GET methods mainly and whether this would be a solution to my requirement.

Photo streaming uploading protocol

In this age of *chat applications and various messaging software, I was wondering if there is already an official protocol (RFC) that would follow the following basic flow:
Client connects to Server for a new session
Client uploads an image (or video) with metadata information (size, resolution, format) to server
Server does some work (not part of the protocol)
Server replies with REJECT then client goes to 1.
Server replies with ACCEPT then client stops and gather the result as part of the reply from the server
I have a proprietary solution now that does the basic (supports basic formats) and as we know, the devil is in the details so I wonder if some existing protocol would cover the stream format and more unhappy paths I may have missed with this simple design.
I'm not aware of any protocol that can handle file probing for you ..
ffprobe is a good open source solution to do this but requires processing power and scale.
So this step must be done on server side, after the upload. You cannot trust the client for such information.
I suggest the cloud approach. Here, we're using Amazon Cloud.
Upload your file to AWS S3. You can use multi part upload for faster upload. No need to scale anything, AWS will do it for you.
Your clients just request a signed URL from your web server. The server return the URL and an ID for this new asset. Your clients upload to AWS S3 using the URL.
Once the upload is done, your client make a call to your server again to say: "I'm done with Asset ID blah". Your server knows the asset is now uploaded and can initiate transcoding, analysis, DB updates, etc.
We do this exact scenario in our project.
For transcoding at scale we use our own open source project: https://github.com/sportarchive/CloudTranscode
This is not an easy business, especially if you want to handle videos.
If you restrict yourself to pictures, then a lot can be done on the user side. You can create several versions of the image in JS, directly in the browser for example or in the mobile app, and upload them to your server. The load is much smaller and you may not need this decoupled architecture.
If you handle videos, you need a solid backend.
Hope this help

Is WCF or Web API best for file upload using streams (large files) in a windows service (Self host, not IIS)

I need to implement a file upload service, which may include some larger files. I initially used a WCF service and was using non streamed (i.e. I sent a byte[]), but would get out of memory exception (reading a file into the byte[] on the client).
I then tried using Streams in the WCF. This seemed to work fine for large files, but the huge restriction is that you seem to need to only send the Stream by itself. I don't seem to be able to also send the file metadata (e.g. filename, timestamp etc)
This service may have many client apps uploading, so I can't really see how to match up file meta data sent in a separate call to just a stream with no other information.
I am wondering if Web API may be a better way. I haven't tried it yet, but in some samples I have seen, you appear to be able to send other data along with the stream.
If using Web API, it will be self hosted (not running, in IIS, it will be running in a Windows service).
So, to me it is starting to look like Web API may be a better choice here? Or is there a way to send metadata with a file Stream in WCF?
Thanks in advance for any ideas!
You can achieve it using WCF by wrapping necessary metadata in a data contract or message contract object. You can refer the implementation on: http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP
Web API is an alternative if your clients prefer to communicate in JSON/XML and you do not want to worry about the serialization/deserialization of JSON/XML in WCF. Your client can send a HTTP POST request with multipart/form-data content type to upload the file using Web API.

Resources