Passing Data from Delphi Client to / from Web Service - web-services

If I create a web service in Delphi XE as CGI executable, what's the best way for it to return data to a client? Say the server uses ADO to access SQL server and the data is stored in a TADODataSet component - what's the best way to get it back to the client through a web service call? Do I need to convert it to XML and return it as a string and have the client recreate it?

With the DataSnap framework it is possible to send dataset between server and client(s).
See more here : can-delphi-2009-build-web-service-that-returns-a-dataset

Related

Run a HTTP server in MySQL to receive data from a client

I want to insert a Json content from android cell phone (as client) into my MySQL database (in server). In order that, at first, I send this Json content from my client to my server which runs a HTTP server using Qt application in C++. Next in C++, I call a MySQL stored procedure to insert the received Json into my database. As we see, there is an interface in C++ (HTTP Server) which I'm going to omit it.
I want to know, is there an approach like running HTTP server in MySQL to handle the above process without a HTTP server in C++? (So I can send the Json content from my client to my MySQL database directly.)
No, the MYSQL server does not expose a JSON interface. You'd have to interact with the MSQL server directly using this. So no JSON, but direct SQL queries to your MYSQL server.
If you don't want to do that, a http webserver is not the only option, but it's probably the most sensible solution.

Simplest Webservice in Delphi

I need to develop a minimalistic webservice.
It should have 2 functions:
senduserdata (a remote app will call "senduserdata" to send info about users, like "ID" and "amount")
sendconfirmation (a remote app will tell "all ok for proccess ID=X, notes are: NOTES)
In past I did a SOAP dll that needs IIS to run, since deployment is crucial in my case and IIS is not always available is it possible to have a standalone exe that exposes the SOAP (or REST) interface?
I succeded in a few minutes using the RemObjects trial and setting SOAP as communication protocol in a server + client project group (note: i need server only).
With a VCL EXE i can deploy much easier (i have lots of customers, and accessing their IIS to install a dll it is sometimes too hard).
Yes, you can use any TCP library for Delphi which includes a HTTP server, for example Internet Direct (Indy). With Indy, you can create a stand-alone application (or better, a windows service) without IIS.
In a RESTful web application, the senduserdata command would be implemented by a URL like
http://example.com/api/users
The clients then use a HTTP PUT or PATCH request to update the users resource.
A senduserdate call for user id 774422 would be written like
LStream := TStringStream.Create('{ "amount":100.50, "currency":"EUR" }');
try
HTTP := TIdHTTP.Create;
try
HTTP.Put('http://example.com/api/users/774422', LStream);
finally
HTTP.Free;
end;
finally
LStream.Free;
end;
In the the Delphi application for server side, a TIdHTTPServer component then listens for HTTP requests for the /rest/users resource and in the OnCommandOther event handler it would extract the request body string, parse it, and apply the changes to the user with the ID given in the resource path (/774422).

How to pass collection<?> over JAX-WS web service

In my project I need to write a web service which will receive Collection<?> as a parameter.. I am using apache CXF.. After I have written the service method I am unable to test it using SOAP UI (It is not generating any request).. My question is - Is it possible to receive Collection<?> over web service? I need to receive Collection of any object type.. Please help..
You need to work directly with SOAP messages.

return a pdf in browser from web service

i am relative new in java development..
I want to create a web service (jax-ws)/web application that will receive some input and generate pdf, and then open the pdf in the browser. I manage to create the pdf (using itext) and open it in the broswer using servlet (with FileInputStream etc).
However i do not know, how to return the servlet from the web service.
What should I do, so when I call the web service to receive a pdf via the servlet ?
If you've returned PDF from servlet, it means your servlet sent PDF stream as output and probably set content type as "application/pdf". This works fine in the browser and this is the right way to do it.
However, you cannot easily invoke web service (no matter whether it is JAX-WS or any other stack) from the browser. Web service call requires POST and strictly defined SOAP content. You can, however, use AJAX to call web service, but that is a different story (also look at REST).
If you want to return binary data from web service (please keep in mind that web-services are for machines, not for humans using web browsers), you have two options: either serialize the binary data using base64 or use multipart HTTP response (MTOM standard, see for instance: http://www.mkyong.com/webservices/jax-ws/jax-ws-attachment-with-mtom).

Send XML file to Web Service using Java

I want to send an XML file to a Web Service.
The Web Service is a java application.
I know the endpoint of the Web Service.
Typically I know I have to create the request and send it as an http/https request.
What I want to know is what would I have to make to send the request - as in what development tool could I use e.g. Visual Web Developer (preffered as I am familiar with this) or Visual Studio? And what sends the request - e.g. another Web Service, a Website etc?
Where do I even begin with this?
Any comments are much appreciated.
Where do I even begin with this?
One purpose of a Webservice is loose coupling. So it depends on what you want to do. You can write a simple program in what ever language which constructs a request and sends it. You can write a Webservice on its own which uses the other Webservice to handle it's own requests.
You can handle this in a very simple or complex way. You only need to be able to generate a request (per xml) and send it.