Passing a variable/s to a blob for HTTP Call Magic XPA/XPI #ria


Darren
 

Hello Guys,

I seldom use Blobs and how to I send 2 variables in to a blob for a httpcall ?

variable test1 is alpha10
variable test2 is alpha5

my blob variable is blob1

how to send test1 and test2 to blob1 using httpcall?


Andreas Sedlmeier
 

Hi Darren,

Is that server, where you want to send your data (that Blob) to, controlled by you ? Then you can serialize your variables into that blob using any format you want, a concetenation of name=value pairs or something more verbous and structured (JSON and/or  XML are good candidates, ...). You can do that because you know how to deserialize that on server side then where you receive the content of the blob. A 3'rd party can't - you need to comply with what they expect and can handle.

All  Magic String functions do work on Blobs and you can use a Blob variable as I/O entry and treat it like a file. JSON you could produce with Output Merge or .NET, XML too - or with XML direct access functions, ...

There's also the Magic buffer manipulation functions for putting stuff into a Blob. From those I would however rather stay away. Those are for friends of machine language and assembler programming ^^

When you put character data into your Blob you should use a Blob ANSI and UTF-8 encode all your character data. Binary and Unicode Blobs might result in some encoding issues but you may never experience those resp. have to deal with that stuff.

Andreas


Darren
 

Hi Andreas,

I will send the blob to XPI generated HTTP. it's just a group of Alpha characters.

Yes I made it ANSI, I just updated my blob variable consisting of 3 alpha variables(A,B,C) like:  A&B&C

 

Thank you for your response, I have been used to using "Call Remote to communicate with iBolt" but since we are migrating from UniPaaS / iBolt to Magic XPA 3.3a /XPI 4.7 we need to opt for HTTP since "Call Remote" is not anymore supported.

 

Best Regards,

Darren


Darren
 

Hi Andreas,

 

I took a screenshot on how it looks like when using "Call Remote".

[img]https://i.imgur.com/UFb5sZg.png[/img]

https://i.imgur.com/UFb5sZg.png


Andreas Sedlmeier
 

Hi Darren,

You can have a Magic program on server side with this set of parameters too, just give it a public name and set external flag. You can now invoke it by http request (http GET/POST) - if your application server is connected to a http server and a broker.

You just have to be aware that you cannot send the parameters from client as is. You need to form-encode or multipart/form-encode the data. Then the Magic requester is able to read the name/value pairs from the request and assign it to the parameters of the program. Alternatively yo can set them in Task Prefix of your server side program with GetParam(<form variable name>). You can use CURL in order to do the encoding and the http request (with correct content-type). The Magic http functions are just to dumb for this and require you to do everything yourself resp. manually.

It might be that you have to add a "-ARGUMENT=" parameter in order to be able to use parameters. Not sure anymore, this stuff is a while ago and I have no access to sample code at the moment.

A Blob with XML/JSON I do actually consider the better idea but I have to admit that I currently do now know if you would get that working with a Magic Internet requester. You have to play with the content-type of the request in order to get it thru the requester without the requester trying to decode it , ... 

Thats all btw. "web server + web client" stuff - which you do not need because your client is not a browser but a Magic application. You should implement webservices (SOAP/REST) or message queues instead.

I hope I did not confuse you too much. Try to get the http request working with CURL and then think about SOAP/REST instead . I can help if you experience issues.

Who told you btw. to use Magic http request as alternative to Call Remote ? MSE ? Lol.

Andreas


Darren
 

Hi Andreas,

We have tried passing directly a value thru arguments, but for example I have 30 arguments, then the url will be really long.

 

Yes MSE instructed me/us to use HTTPCALL instead of remote call, do you have any suggestions on what other alternatives can I use besides from HTTP?

 

Best Regards,

Darren


Andreas Sedlmeier
 

Hi Darren,

You have to use Http POST not GET. Your parameters you then write to a Blob, on the URL you do not pass anything but the URL to the requester (https://<yourserver>/scripts/Mgrrqispi.dll). Now, if you have only a "Magic & Internet" application running on serverside you do have to put two more name=value pairs in your Blob in order to tell the requester what to call: AppName=<your appname> and PrgName=<Your prgname>.

Http is not the issue, just Magic Http requests with "Magic & Internet" on server side is a strange replacement/recommendation as a replacement for call remote basically. I would have expected that they recommend REST and/or SOAP as a replacement. REST is a pain in 3.3, maybe there is better support in 4.X. SOAP with Apache Axis should be fine (and frees you from all that parameter encoding stuff, ...)

A real alternative would be message queues. You have nice features like guaranteed delivery then, good monitoring, ... . You do not require a web server installation and there's other protocols, ...

Best regards,

Andreas