I'm new in Mobile dev. Going to use C#. I'm going to write small android(maybe iOs in the future) app. And I can't figure out what I need to use as web server. I want mobile client to send requests to server and get result from it. Best idea I have - use WCF web service and json.
Is it a good idea?
What can I use except WCF?
What could I read about web servers for mobile application?
P.S. Link for some tutorial will be great.
There are tonnes of tutorials out there on this topic.
I would use socket connections
For C# you can create a TCP Listener using sockets
using System.Net.Sockets;
https://msdn.microsoft.com/en-GB/library/bb397809(v=vs.90).aspx
and like wise for the android
TCP sockets would be an easy implementation.
http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/
As for Android and connectivity.
the Android developer platform is always a good start.
developer.android.com/training/building-connectivity.html
Or you could create a Rest interface in c#
codeproject.com/Articles/112470/Developing-a-REST-Web-Service-using-C-A-walkthroug
and make a http call in android. depends on your intended application to what will be better for you
Why REST + JSON is preferred over SOAP for mobile web services
http://www.bamboorocketapps.com/rest-json-vs-soap-xml/
Related
I need to host ASP.NET based app as Azure Web App which should communicate with WCF based Azure Web App. ( WCF app is also an azure Web App not an on-premise app at all).
What are possible ways to achieve easy and flexible communication between both app services?
Do we need to establish a communication channel specifically?
Both Apps under IIS On-Premises are used to communicate without any problem over NET TCP protocol. But I think now we need both services to communicate over HTTP instead of Net TCP?
What problems we may have?
What things do we need to bear in mind?
First of all, we need to be clear that azure webapp only supports ports 80 and 443.
Secondly, in your project, you said that it runs normally in local, because I don't know what you mean by communicate, and I don't know how to achieve it. Normal communication may be socket or websocket, etc. It is not clear what communication you are talking about. If it is socket and you need to use a port other than 443/80, then it is not supported.
But I know clearly that azure web app supports wcf, which means that both of your webapps can be deployed successfully and run normally. If there is a problem, you can update the error details in the post, and we can provide you with further assistance.
I'm starting up a little code project to learn from the process, but I am not sure what's the best way of communicating between the different parts.
First, I have a pure html/js client where the users need to get live updates frequently.
Secondly, I'm considering having a web api application running to provide data.
Thirdly I have a console application running, that needs to communicate with the web api application.
So I'm thinking about using WebSockets all the way from client->web api->console app, but I have trouble making it work. I can make the console app work as a server, but I can't figure out how to make the web api work as a client, so that when it spins up, creates a connection to the console app, and keeps it open for communication, while it delivers data to the clients upon requests.
I tried with different implementations and I have ended up with SignalR, as it seems like that's what people use today :)
Since I have all these problems getting a connection I am wondering if there are better ways of sending data that fulfills my requirements?
If WebSocket (using SignalR) is the way to go, can you provide some links with working examples? I have tried all the top links from Google with no success ^^
Thanks in advance
Your WebAPI project can act as WebSocket server as well. Check this link that uses an IHttpHandler, but you can also do it in a WebAIP's controller how is explained here : Using WebSockets with ASP.NET Web API
The console application should connect as client, using for example ClientWebSocket class.
WebSockets are persistent full duplex connections, so once the client is connected both ends can push information to the other end.
I am currently trying to find a solution on how to create (not consume!!!) a RESTful service with Xamarin for Android and on Windows Phone. I already searched for it, but only found libraries and solutions on how to consume a RESTful webservice on those platforms.
Do you know any good library to create a webservice on those platforms or any hints on how to implement a simple werbservice (not using ASP.NET)?
TIA Octo
The Xamarin.NET and WinRT frameworks (and their package ecosystems) have pretty comprehensive support for web services etc. from a client perspective, but not so much if you want to act as the host. You can't install something like webapi or signalr host into a PCL, or even the native platform projects.
Based on your clarification comments, I would suggest one of the two approaches below. I will assume that the RESTful requirement is more of a "nice to have", and the "calling methods with parameters and getting results" is the priority.
1. Make the mobile apps clients too - remove the hosting requirement from the mobile devices by adding a hub on another server with the full .NET profile. Both your mobile apps and your "test runner" connect to this and the hub routes the messages between them. SignalR would handle this easily. This option is not at all RESTful and requires an additional server, but is quick to get up and running and will easily support your desire to pass json messages back and forth.
2. Go lower level - Use sockets to facilitate communication directly between the mobile devices and "test runner". The mobile devices can open sockets for listening, and your "test runner" connects to them direct. Again, not RESTful and a bit more involved - you need to define a (hopefully) simple protocol (e.g. {length of type name}{type name}{length of payload}{payload}) and use that to send send and receive json - but it avoids needing a middle machine for routing.
I'm new to the community, I hope I'm asking right.
I have a WCF service that should receive connections from both "web app client" and "Android app".
Is it possible to do this?
As I understood the best way to connect to Android is using JSON, but how can I manage the connection to the web app?
Thank you.
Your question is right!
(i)Yes it is possible, since wcf services can be consumed by both web and android app.
(ii)You can either use SOAP/JSON for android and web app, your connections can be maintained in the web.config.
Yes You can use WCF for both web client as well as android, I would suggest you to use Restful WCF as Android does not support Soap by default.
I am developing a smart device application, which is going to communicate with a wcf service over wi-fi. As there is no option to add a service reference into a smart device project I decided to use the NetCFSvcUtil.exe. Everything works great!
But...
In the end I understood that the application must interact with the service in the background.
Having read this article Microsoft .NET Compact Framework Background Processing Techniques. I decided to use the Asynchronous Web Service Call. There http://msdn.microsoft.com/ru-ru/library/aa347733.aspx I found the /async parameter, but it appeared to not work for the NetCFSvcUtil.exe.
What can I do to get the async proxy for my smart device application? Is there a way to generate it or I'm expected to add async methods to the interface with my own hands? Maybe it would be suitable for .Net CF to use SvcUtil.exe to generate the async proxy in my case?
A further more information like which platform you are using to build your Smart phone application would be helpful.
I have done Blackberry development and consumed web services. There are two ways you could build your web services
RestFul Service - Consumption of web services would be pretty easy. Posting data could be a little pain as multipart form data is posted as stream in Wcf - Rest Starter Kit
Soap Service - If you decide to use SOAP, then for blackberry and Android you have to use preverified KSOAP -2 to send and receive soap messages between your app and the web service. If you decide to use KSOAP -2 , go back ASMX services. Somehow WCF services does not communicate with KSOAP -2 (due to change in SOAP version or something) where as a simple ASMX service works pretty smoothly. There are dozens of article which you could use to learn how to use KSOAP
he original idea was to host it in a windows service...
Windows Services could never be web facing. If you want any thing to be web facing, you need a Web Server !
In the end it worked. The "Add web reference" tool created a proxy with Begin/End async methods and the proxy interacted with the wcf service hosted by a simple console application (later a windows service) through the URL property of the proxy.