The REST webservice basic is a web service that can receive http/https calls using none or basic authentication.
For production REST webservice OAuth2.0 is recommended.
The parameters of this workflow input type are:
Path
The url this will be called, e.g. invoice will open the address http://localhost:8086/basicws/invoice for listening.
(It will be https, if you have enabled https in InterFormNG2, and the port number 8086 must fit the port number configured for InterFormNG2 (8086 is the default port number).
The address have to be unique for all tenants and workflows.
Input type
The input type that will be received, default is XML
Username and password
Blank means no authentication, if something is entered, then the user name and password will be checked using basic authentication
Receive type
Body only means that the received content is the entire body in the form post, this is the default. The result will be the resulting payload in the workflow (e.g. PDF)
Parameters means Backwards compatible mode, close to InterFormNG, where xml= is the file content and report=true will return a report in XML.
Character encoding
If special encodings are used, then this can override the default encoding detecting mecanism. If empty, autodetection is used based on headers.
Store request for later forwarding
You need to enable this option, if you intend to use the workflow component, Forward webservice.
When the workflow is done the current payload of the workflow is returned to the web service caller. This can e.g. be a PDF file, that has been created with the workflow component, Create PDF document or it can e.g. be an XML file which indicates if the workflow was successful or not.
Relevant functions are:
You can use this workflow component to set the mime-type (content type) of the file, that is returned from the workflow.
If you want to return a transformed XML file, then you should consider to first define a transformation template and then activate it via the workflow component, XSL transformation.
If you change the payload you might want to save the initial payload with the component, Payload to named property and later retrieve the original payload again with Named property to payload.
Simple example for a body post in Java:
String ng2Url="http://localhost:8086/basicws/invoice";
URL url = new URL(ng2Url);
HttpURLConnection con = (HttpURLConnection)url.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/xml; UTF-8"); //Content type is important
//Uncomment next line to use login //con.setRequestProperty("Authorization", "Basic "+Base64.getEncoder().encodeToString("login:secret".getBytes()));
con.setDoOutput(true); con.getOutputStream().write("<xml/>".getBytes("UTF-8"));
int code = con.getResponseCode(); System.out.println(code);
InputStream is=con.getInputStream(); |