How to Use or Consume a Rest Server function - rest

It's my first time to deal with REST Server stuffs.I followed this tutorial and I was able to create a Rest Server. I was able to create a function DoSomething that queries our database and result a string. I was able to run the Rest Server, then Open Browser, and my function DoSomething is successfully resulting a value. Now, I want to use DoSomething in a separate application. I tried to follow this tutorial link but I can't comprehend the next steps after setting TRestClient.BaseURL := http://localhost:8080. Am I on the right track? How can I consume DoSomething in other application?

Related

How to use Google Action Builder with my own server

I want to develop an action to google assistant. So i red the documentation here https://developers.google.com/assistant/conversational/overview and i followed this tutorial https://www.youtube.com/watch?v=Z1hxvniJ18s
It s worked and i was allow to develop and test my app in the simulator. The problem is that when it's come to webhook i don't totaly understand how it's work. On the webhook icon i got this
The seconde one allow me to use Google cloud function and firebase but i had to add my billing account to make it available. I also get a console where i can code my fonctions and my responses.
And if i am correct, the first one allow me to connect to my own Api. But i can only enter one field that is the URL adresse and nothing else so how do i code it? Also i see everywhere people using node.js and i would like to use php is it possible?
To sum up my problem, i would like to know how i could connect my action builder to an other service(Api) than google ones? If it's possible to run my server in php and how do i interact with my google action?(I think it's by sending json back and forth but i'am not sure how to do it?) Finally i would like to know if it's possible to test it in local server with mamp and phpmyadmin for exemple to test the answer of the server?
I would be very grateful if someone could help me, show me how to set up all this.
But i can only enter one field that is the URL adresse and nothing else so how do i code it?
When you develop your webhook, you will need to have a single publicly accessible endpoint to connect with. This endpoint will receive an HTTP POST request and you will need to respond with an appropriate response.
Also i see everywhere people using node.js and i would like to use php is it possible?
Any language that can run on a web server can work. Node.js is one that is used a lot, but PHP can work just as well. You can create an actions.php file and then enter an endpoint address https://example.com/actions.php that will be called. You may need to refer to the Request and Response reference for the expected format.
if it's possible to test it in local server with mamp and phpmyadmin for exemple to test the answer of the server?
It's somewhat possible. You'll need to have some method of sending mock requests to your local server, which might be as easy as using cURL or other tools like Postman.
Unfortunately my personal experience with PHP tools is limited, so I can't necessarily walk-through the specifics. But it does seem like you know these tools a bit more and should be familiar enough to be able to get started.

SOAP UI mock server groovy scripting

Currently i am having two SOAP projects(A and B) imported from WSDL files.
I created a mock server with one of the projects(A) and from my application i am able to call the mock server and get response.
Now i want to go further and try to invoke a request to another service situated in another project(B) when a soap operation is called in mock server project(A).The Project B is a call to another application.
Can i write groovy scripts to do this?
so whenever an operation A1 is called in project A after a time lapse a request needs to be sent from project B which might be an operation B1.
Here actually i am trying to simulate an external application using soap ui.
I understand i can do it by writing a program using java but thought i could do this in short time using soap ui.
As question i wanted to know if my thought is right of using soap ui or should i go do it through another tool or writing a java app.

RPC not working on addclose handler

I'm facing a weird problem in GWT. I generate an excel file on server side for users to download. But after the download the file should get deleted.
I have put logic to delete it on server-Side on 2 occasions. One when user logs out and another when browser is closed.
When the user logs out, it works perfectly as it has enough time to make a call to the server whereas in case of addclosehandler, it loses connection and file remains as it is.
i.e. the method on server side does not get executed.
I tried to find another way to call the method directly by importing the package and inheriting in gwt.xml. But an error was thrown at the compile time and rightly so that server side cant be inherited.
Please get me out of this.
Thanks in advance.
But after the download the file should get deleted. I have put logic
to delete it on server-Side on 2 occasions.
This does not have to do anything with the client. I don't know excactly how your progam works but generally it should work like this:
Client makes a request
Servlet generates the bytes (Is there really a need to store the bytes in a file?)
sends them to client
And that's it.

Test symfony restful api with phpunit and doctrine

I'm trying to pull-of some tests for my RESTful api functions.
For this I did the following:
Installed PHPUnit.
Created a new database for testing.
Created a new enviorment (test) and changed the doctrine config for it.
Created a test.
My problem is this:
When performing a request (somedomain.com/api/somemethod) -> the requested page doesn't know i'm performing a test on it -> so the data it uses is the production/development database and not the 'test' db i have created for the tests.
(the script using test db, the requested page uses normal configurations).
Is there a way to solve it without touching or modifying the API code/behavior?.
Thanks.
Since you said you're requesting somedomain.com I can only suspect you're firing requests over HTTP.
Symfony is made to be easily testable and you can perform functional test without ever making a real HTTP request. Instead, it will make a request object and tell it's kernel to handle it as if it were coming from a real client.
There is a chapter in symfony book on this: Functional tests
If you use method described there (using Symfony BrowserKit client and paths instead of complete urls), Symfony will have it's kernel booted in test environment and will handle request like that.
If, however, for any reason you are unable/don't want to do it that way, and want to fire real HTTP requests, I suggest you to make a file in web directory called app_test.php. In that file you should boot the kernel in test environment and make sure your tests are actually hitting that file (instead of app.php or app_dev.php). However, have in mind that this file will be publicly available and as so, it will cause a security hole so make sure to guard it somehow (check app_dev.php for hints). As an idea, you could require specific key to be provided in request header to allow it to pass on. Or if it will be tested from a single machine, you could also guard it by IP, or whatever works for your case.

How to return an Excel workbook from a web service

I was asked to create a web service that would be called from a macro in an Excel workbook. The reason behind that is because we have a web application that returns reports in Excel format to the users (and there are several different reports), but some of the reports take a long time to generate – even to execute the stored procedure on the SQL Server. So this web service is to be used to short-cut the long-running process in the web application.
My problem is understanding how the web service would return the workbook - can that be done without using XML/XSD?
Someone tried using the CarlosAg.ExcelXmlWriter in the application previously, but never got it to work.
If you don't want to use XML, you could probably just send it back as a base 64 encoded byte array. You'd just need to write another macro to decode it and write it to a file, I suppose.