How should I call a WebService from a Windows Service Application? - web-services

I'm facing a annoying problem for the last couple days. I've made a Win32 application who calls some functions via WebServices. I've used the WSDL importer in order to get the WebService methods. Within the Win32 application I am able use every method to access this WebService, however I need this software to run as a Windows Service.
So I have created a Windows Service Application and added the WebService units. But now when I call these functions I get a ERemotable Exception:
There is any difference in the process of make use of webservices from a Windows Service Application and the process used to Win32 applications?
If anyone can give me a hint, or point me some direction I'll be very glad.
PS: I am using a HTTPRIO component and Delphi XE5 in order to do this.

Related

How to correctly do unit testing with this configuration

I've got a WPF solution that interacts with Webservices in order to retrieve data.
My application is divided in modules for manteinability and there's a 1:1 correnspondency between WPF modules and Web service's part. I use ServiceStack as layer to perform web service call and my WPF modules use repository pattern to isolate calls.
WPF assemblies are compiled with FW 4.0 (since it has to bee used on XP also) meanwhile Web are FW 4.5.2
I was wondering what's the best solution to debug such repositories without the need to have a Web server configured for this purpose. In my mind if I've the possibility to run both on 4.5.2 I would set up a self-hosted webservice that loads the web module and performs call without having the need to have a web server configured for that... any suggestion/proposal on that?

How can I call an UWP API from a C++ desktop application

I would like to access Bluetooth LE devices using the corresponding UWP APIs. However, my application is a "classic" C++ application (3D game) that can't run as a UWP app. Is there a way to do that? Accorind to enter link description here these APIs are published, but I don't know the steps to access them I have only found some posts for Windows 8/8.1 apps that include the Windows.winmd and Platform.winmd metadata files and set the /ZW compilation flag, but this doesn't seem to apply to Windows 10.
You should be able to do this, as the Bluetooth classes (e.g., BluetoothLEAdvertisement) are marked up with DualApiPartitionAttribute (callable from desktop and UWP apps).
Using one of the older Win8.1 desktop samples should give you a good starting point for calling the APIs without requiring /ZW or referencing the winmd files. A good example is the desktop toast API sample.
If you go that route, you can use classic COM to create the UWP/WinRT classes via WRL helpers.
You can use the web that you make a web server and the C++ application use the same server and if UWP send the info to server then it will send the info to C++ application.
To safe,the UWP can't use the desktop app.

Call REST Service from Win32 application

I have an Win32 application which runs on the Windows server (2003 & later). My application has to call a REST service to POST some JSON data.
How can I proceed with implementation? Which library or SDK should I use to call REST service from C++ application.
Please suggest.
Thanks in advance.
I'd suggest using modern C++11 Casablanca REST API developed by Microsoft. This API is now included into Visual Studio installation package. You can also use WinHTTP API which is kind of legacy stuff. There is also MFC/ATL implementation called ATL Server that does include HTTP Client classes.

Calling c++ in web-services

In my mind a webservice is a service that create a link between some applications. What I want to do is calling a c++ program installed on a server into a webservice.
However I have found how to call a webservice in a c++ program but that's not what I am looking for.
How do you call a c++ code into a webservice ( I am using VS2013 btw) and is it relevant to do that.
So my question is : How do you call a c++ code into a webservice ( I am using VS2013 btw) and is it relevant to do that.
A web service is a service accessible remotely, which publishes several "endpoints".
Each endpoint corresponds to a function call (possibly implemented in C++).
To call a webservice endpoint, you must serialize the input parameters of the endpoint in a format accepted by the web service (in practice, this usually means generating a SOAP/XML document that contains the values of the parameters), then sending the serialized document to the server. The server then de-serializes the parameters, calls the function, serializes the result, and sends it as a response.
Webservices publish their endpoints (their accessible/callable APIs) in another XML standard, called WSDL, and public web services are usually listed in a public directory.
For this you will need a networking library usable in C++ (see gSoap), or an implementation of your own, on top of a networking library (see boost::asio).
It depends on in which language your web service is coded.
If it is PHP, see the function system to run another programme that you can code in any language you want (including C++ then).
If it is C/C++ on Linux, see the functions fork/exec's to create a new process and run another programme in that new process.
If it is C#, see this tutorial on Process.Start.
If it is Python, see the subprocess package from the standard library.
Anyway, if your web service is in C++ and that the code you want to execute is in the same programme, you can just do a function call in your web service's method.

How to connect a C++ COM To a WCF Service

I'm looking to a way to connect a COM+ legacy application to a WCF Service, i have been researching this since a couple of days and i haven been lucky to find any useful information, can anyone point me into the right direction on this?
I Need the old COM+ component to make calls to a new C# WCF Service so I Need some kind of proxy in the COM Component that abstracts the communication with the Service.
Thanks in advance, i really appreciate any help.
I assume you mean that you have a WCF service, and that the code that runs your WCF service needs to make calls to your legacy application and send that data in/out of the WCF service, correct? If that's the case, then the WCF facet of your question is actually irrelevant.
What you're trying to solve is how to get your .NET application to speak COM to your legacy application.
Check out: Introduction to COM Interop and COM Interop Tutorials.
You'll need to generate type libraries for your COM component, reference them and System.Runtime.InteropServices in your C# project, and then you can make your calls across into COM boundaries of your legacy application code. There are a lot of other examples and tutorials out there if you search for COM Interop Tutorial, for example.
EDIT:
I thought more about your problem. You need to implement a proxy by creating a server that "looks" just like your old server (all the same COM+ interfaces etc etc), and then forwards the request (by crafting a new request) to your WCF service. You can do this in C#. I whiteboarded (archive) the basic idea around it from your original whiteboard.
The WCF service moniker can auto-generate a COM proxy for your WCF service. Your C++ code can call this proxy directly without the need for you to write any C# proxy code or explicit COM interop code.
Look at http://msdn.microsoft.com/en-us/library/ms729739(VS.85).aspx for details.
I particularly recommend this feature primarily because I owned the feature at Microsoft.