Remote Method Invocation Phonegap and C# - c#

I'd like to let my app on Phonegap provoke methods in my C# app. I know I have to run a server on the PC to let the app connect to the PC via local WiFi. But how do I get the Phonegap app to invoke the methods? Are there any plugins for this or do I can use a way more "easy" technique to accomplish this.
Thanks in advance.

If I understand correctly, you want to send or get data from your phone app to or from your pc/server?
If that is the case, the easiest solution would be a REST Web API on the server side(your PC), and then just do standard REST HTTP requests to your API from your phone app. A request could be a GET if you want your API to serve data to your phone app, or a POST if you'd like to send something to your API.
I'm not familiar with Phonegap but if you're using jQuery in your app you could call your api roughly like this to get, for example, all products:
$.get( "http://my-pc/api/products/", function( data ) {
alert( data );
});
I highly recommend ASP.NET Web API, Getting Started
As well as looking into the basic principles of REST, Wikipedia

Related

C# WinForms Application want to use asana API

I am trying to work with the asana API in my C# Windows Application and have several questions I'd like to ask.
When you register your application with asana, it wants to know APP NAME, APP URL, REDIRECT URL. If it's a windows application, what values might I supply for the second two prompts?
When that is entered, you get a client id and a client secret. Is this completely different than the apikey? Is the former for OAuth and the latter for asana, or does asana work in conjunction with OAuth?
Basically I want to take a request like this: https://app.asana.com/api/1.0/tasks//stories?opt_pretty and get back in my application the same json I see when I issue the request in my browser.
You can provide localhost
You should definitely have a look at https://asana.com/developers
Your answer is there https://community.asana.com/t/can-a-windows-application-be-registered/23381 !
Good luck ;)

WCF Service Get Data From Client Application And Send to Web Application (Asp.NET)

This is my situation, I need to get a data from a smart card through a client application, after that I need to pass that data to my web application written in VB.NET(Asp.NET). I've read that its possible to do it with WCF Service but couldn't really figure it how. I've google about it but all the tutorial only tell process of web application and web service. But in my case, it is client application to web services to web application.
Any help/suggestion is appreciated. Thanks in advance.
For your client application (for example, a winform), take a look at this:
Smart card reader development with .Net technologies
You can after that create a WCF or REST api that will receive your request after reading whatever you need from your smart card (from your client application):
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api
Finally, you have to send your data from your client application to your webapi:
How do I make calls to a REST api using c#?
Note: If you want to create a wcf instead of the web api, take a look at this:
https://www.codeproject.com/Articles/42643/Creating-and-Consuming-Your-First-WCF-Service
Let me know if you need more info. Also, provide more information about what you already have and what you don't (do you have the client application?)

Building a remote command for Elpis in C# through HTTP API

I am helping to build Elpis, which is an open source pandora music player, built with C# and WPF.
Now what i want is to add an HTTP API so that the user may control the program through a browser, like play/pause, like/dislike the current song.
The point afterwards is to control the program through a mobile device accessing the HTTP API.
How exactly should i build the HTTP API so that it can control it?
Github for the project: https://github.com/adammhaile/Elpis
Without knowing why exactly you want the user to control a GUI application via the browser, it's hard to give you good advise.
Assuming you are running your GUI on Windows, take a look at OWIN and the project Katana. They allow you to easily host HTTP interfaces in your own application.
It may be overkill for your project but I would suggest using ASP.NET Web API so that you can build backend web services.
The easiest way to do what you want, assuming you really want to "control the GUI remotely" is to just install TeamViewer on your PC and on your mobile device. Then you could remote in and completely control your GUI.
But I what I think you're after is something more like Google Music. Where you can stream your music through the Internet and onto your mobile devices. If this is the case, I recommend you look at the ASP.NET Web API.
It's not hard to build a web server in C#. You can embed it into your application, and expose parts of your application to HTTP endpoints as an API. You can use the HttpListener class which is part of .NET, and do everything from the ground up yourself. Or you could use something like Nancy, which is a lightweight framework that provides a lot of useful scaffolding like URL routing.
Ended up using Kayak(https://github.com/kayak/kayak) for my self-hosted API.
The example of integration can be seen here:
https://github.com/adammhaile/Elpis/blob/master/Elpis/WebInterface.cs

Running web-application offline on android

A while ago I created an ASP.NET MVC Web Application for android devices. The application also used jQuery mobile to set up navigation etc.
At the moment, the application is simply being hosted and the androids webview accesses it that way.
The application works as expected, but I was wondering, is it possible to store the MVC web-app on the phone/integrate it into the apk?
I would like to be able to have it run the web-pages while the device is offline. I know it is possible to run simple HTML in the webview but I haven't been able to find anything about something like an ASP.NET MVC web-app. Is this done using phonegap?
Thanks.
I don't think you can do it directly with PhoneGap, from the PhoneGap FAQ
Q: Can you use PHP/ASP/JSF/Java/.NET with PhoneGap?
A: A PhoneGap application may only use HTML, CSS, and JavaScript.
However, you can make use of network protocols (XmlHTTPRequest, Web Sockets,
etc) to easily communicate with backend services written in any language.
This allows your PhoneGap app to remotely access existing business processes
while the device is connected to the Internet.
So if you are going the PhoneGap route, you'll have to write it in HTML/CSS/JavaScript. However if you more comfortable in .NET and C# then there is always Xamarin Android which has a free starter version that you can try out. Do realize though that if you go that route it will be a mobile app and not a wrapped ASP.NET app.
If I understand correctly I think what you want to do is serve your data via a web service (MVC4 web api is pretty simple to setup). Then you'd consume that data with your android app and you could more easily cache that data for offline use.

How to access PHP based service in Metro style app

we have a web service which will be used by the application to interact with the Server.
This service is a PHP based service. When we add this as a service reference in metro style app we aren’t able to do access any methods.
We tried the same URL in other application as a service reference and we were able to access the methods.
The service URL is http://sanity-free.org/services/ws.php?wsdl
Please let me know how can we access this method in our application.
Thanks
Mani
I'll describe you my case. I hope it helps.
I have a metro app that communicates with azure sql via asp webapi. The webapi is hosted in cloud and it is a connector for metro to my db.
It is very simillar to your case. Create public methods that are available from world. Than you need just to make sure that the data are returned in a good format (by your php service). I'm prefering json cause it is easy to code,decode ant it's lite (that is very important in a webapp).
I connect with my api this: http://domain.com/api/Content/get or http://domain.com/api/content/getbyname/my+name
With this urls I'll get whole content or content by title
This is not a 100% answer for your question but can solve it :)

Categories