How do I can call a jar file from wso2 - jar

I am new to esb WSO2 and I need to call a .jar with WSO2 parameters. I think I need to create a endpoint and call the jar file. Is it right?
Thanks for all.

I have done this using the Script Mediator (Groovy language). So from within the Groovy script I called my custom method by passing it the payload as JSON and saved the return value of that method as the payload. I used JSON for the payload, but feel free to leave it to default XML. You can also pass parameters, not just the payload, to your custom method.
<script language="groovy">
println "---------- start java call -----------"
mc.setPayloadJSON(new my.own.package.MyClass().myMethod(mc.getPayloadJSON()))
println "----------- end java call ----------"
</script>
Added my custom jar, JSON and Groovy jars under {ESB_ROOT}/repository/components/lib and bounced the WSO2 ESB.
There are probably other ways to achieve what you need.

Related

How to call an API platform endpoint from a Symfony command

I have a working API platform endpoint, which supports POST, PATCH & GET. Just for an example, it's a book endpoint:
/api/books
Now, I have a new task of creating a Symfony command, which will have a part where I'll be creating a new Book object and will save it in the database.
I am into the direction of creating a new Service class to normalize the data to Book object, then using EntityManager to persist the data to DB, but since I have a working POST endpoint in API Platform that basically does the same thing, is it possible for me to call that endpoint instead from the Symfony command that I'll be creating?

Call a REST API from Kusto function

I have a logs endpoint rest url that I want to call and get the contents by calling a function. In a simplified way, create function like below.
create function getData(url:string)
{
let data = curl GET url;
print data
}
//Call it.
getData("<some rest url here>")
The documentation from Microsoft seems to talk about Kusto's own APIs not not how to call an external API. Am I missing something?
The documentation you reference relates to calling Kusto service REST APIs.
Kusto query language is a query language, not a open-ended programming platform.
Call-outs to external sources such as SQL Azure are possible, but subject to certain restrictions, primarily security-oriented by nature.
See external data operator, sql_request plugin, and callout policy articles.

MarkLogic I don't know how to get all the result

Hello I am trying to read a module with this code:
(: Entry point - must be a read-only query. :)
xdmp:invoke(
'/path/mydocument.xqy',
(xs:QName('var1'), 'test',
xs:QName('var2'), "response"))
I am new in MarkLogic, I am using groovy and the api to connect to it, but also I saw I can invoke the module with this and indeed I did but it returns me
your query returned an empty sequence
I want to know if I can query xs:QName('var1'), 'test', changing test with a wildcard or how can I get all the information from the file called /path/mydocument.xqy?
I tried to use this:
xdmp:document-get("/path/mydocument.xqy)
but it says the file is not found. Although, if I use invoke I can query it, but I don't know what are the values I have to pass. I was wondering if there is something like sql using %% or something to give me all the data.
To answer the first question: "I am trying to read a module "
IF the module is in the database, then you must query the Modules database in which the module resides.
If the module is in the filesystem then you cannot directly access its source as a document but you can by executing xdmp:filesystem-file()
Simplification:
With the Default configuration of the server and REST client, user placed modules are in the "Modules" database and user placed documents are in the "Documents" database. This means, if you do a GET (read a "Document") with no additional parameters, it will return documents from the "Documents" database. Assuming you are using the default configuration for client and server, this would result in the behavior you are seeing. E.g. your Module code is in the Modules database, doing a GET for it by name will search the Documents database and correctly not find it.
You don't mention, and I don't know, the groovy library being used, but the REST API itself and all implementations of general purpose ML REST client libraries I am familiar with have options for overriding the default database with another. If the groovy library supports that, then specify the "Modules" database for your query and it should return the module document. Note: content-type will be application/text not text/xml.
You can simplify things for testing by bypassing the libraries and simply use a browser and try a URL like this http://yourserver.com:8000/v1/documents?uri=/your/module.xqy&database=Modules
Ref: https://docs.marklogic.com/REST/GET/v1/documents
Making the appropriate changes to the path and server for your use.
If you are still confused, then you should start with the basic MarkLogic tutorials and work through them one by one. You will most likely succeed faster by doing this then jumping straight into coding you don't understand yet.
DETAIL:
Note: The default behaviour is to EXECUTE documents when doing a GET call, using the Modules database. Thus doing a GET of http://yourserver:8000/your/module.xqy will EXECUTE it not return its source.
You will notice the REST API has a uri query parameter. This is EXECUTING the REST API code on /v1/documents which in turn will read the document specified by the uri and database parameters and return it.
I guess I can use:
xdmp:invoke(/pview/get-pview-browse-profiles.xqy,
cts:and-query((
cts:element-value-query(
xs:QName("letter"),"*", "wildcarded"),
cts:element-value-query(
xs:QName("collection"),"*", "wildcarded"))))
although it doesn't return anything

How to log to a file in Redux?

Is there any simple way how to log actions and states from Redux to a file? I found this awesome logger https://github.com/evgenyrodionov/redux-logger, but it seems to be used only for logging to console.
You can't simply log to a file since your application is executed by the browser. If you want to export logs to a log file, you have to add some mechanism to send back this information to server. Then server will be able to put this infos in a file.
Decorate your logger to intercept any log
store any log to a state
JSON.stringify your state
create ObjectURL from your state. (MDN)
Download it from <a download="logs.json" src="${objecturl}" />
Looks like redux-logger accepts a logger parameter where you can specify your own console implementation.

AWS PDF upload through http post

I am new to AWS and I am trying to upload a pdf document to S3 trough an AWS API. I am using an HTML form with a post method. The action of the form is the URL of the deployed API. The API is integrated with a lambda function. My question is how can I extract the uploaded file to proceed within the lambda function, to perform some processing before uploading to S3. Is it even possible?
I have tried the instructions found in this post:
Passing HTTP Post from AWS API GW to Lambda
However, I return the event from the lambda function and this is what I get:
{file: file.pdf , acl:private,
success_action_redirect: http://localhost/, AWSAccessKeyId:my_aws_key}
The file I uploaded is called file.pdf.
Any guidance will be appreciated.
A pdf file is a binary format. API Gateway does not currently support binary data. We know that binary data does not work and there are no workarounds to make it work reliably. A number of customers have requested that we add binary support to API Gateway and it is prioritized on our backlog.

Resources