Write Json to server endpoint - c#

I have an Ubuntu server instance running in Amazon EC2.
I want to write json to an endpoint in that url, for instance "http://myurl/myendpoint".
How do I create this endpoint and how do I write json to it with C#?

Information you gave are too scarse. What exactly are you tryingt to achieve? Do you have a REST API deployed on that server? If not, then you probably want to create a REST Api. You can use it to create a mechanism that will be able to handle requests/responses.
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api

Related

How modern angular app consumes different traditional based services

i have a requirement to convert different kinds of services like soap based services, wcf xml services,web services that is currently running in silverlight app. so conversion we have use angular as front end and server side currently don't do a modification.
In this case, question have is
is it possible to consume different structures of xml services like soap, asmx ,web services in angular directly. or need to deserialize in angular.
Note : currently we don't modify existing services responses,because the client already using existing app.for time consumption,have only change the business logic in angular.
Or else we need to write any webapi or wrapper to consume the service and to convert to json and host it in server to consume json,
is there any other techniques ? suggestions are more appreciated
Ideally, this should be handle at the server - by simply adding a new endpoint should do the work.
However, if your ask is not to change anything on server, below are the npm packages you can utilize.
node-xml2js
ngx-xml2json
More reference:
Angular2: Convert XML to JSON
Angular: Convert XML to JSON

Prevent unwanted access to my web service

I have coded a C# MVC5 Internet application and I have a Web API 2 web service that returns JSON data. I am retrieving this JSON data in an android application.
How can I add a feature to the web service such that only my android application can retrieve the JSON data? I am wanting to do this so that other web users cannot hammer the url and the web service will not send my data to unwanted applications and/or users.
Is this possible? If so, how should I do this?
Thanks in advance.
You have various ways to achieve this in fact.
For example, you can store a key in your android application and use send this key together with the request to your WebAPI. Your webAPI will than check if they key is valid and if it is, it will return the JSon.
However, there's no way to ensure that nobody else can request and get your data. For example by reverse engineering your android application and extracting the key, or by monitoring the network traffic and find the key in there.
You need to understand that there isn't anthing that guarantuees you 100% security.
See it as the following:
You have an open door right now, you can close it little by little, but closing and locking down is not possible. There will always be gap. A house also can't by made burglar proof, but you can make it very hard for a buglar to enter.
Go to this link Web Api. I have used the individual authentication for my web api. When you will register the user the response you will get is access token and use that access token as Authentication header in your ajax call if you are using Jquery ajax to call your Web Api. Refer this The OAuth 2.0 Authorization Framework. Hope this help you.
Are you looking for something like this?
http://httpd.apache.org/docs/2.2/howto/access.html
If you have other web server, there should be appropriate means to support such.

How to Create a JSON Restful Web Service in C#/ASP with MySQL as Db?

I followed This to Create a RESTful Web Service which Displays Json as output
So that I can use this JSON in the part of Mobile application,
But Here Actually I have a Lot of data to display I am Creating a Server Side for mobile application so I decided to Store My data in the part of Mysql I successfully stored
But I failed to Display the JSON data As out Put..
Any suggestion regarding this.. please tell me some reference links.,..
You can simply create a simple c# rest web service. To return json data , you will need to specify the return data format on specific operation in the web service. To use mysql for database, you can search for mysql connector for c# on google. You can find libraries to use in your code. Hope it helps !

Send Data Via Http In C#

I am creating Android Application for a school where teachers should be login to the android application and perform some activity on daily basis.
We have a complete existing web based solution for the same and now want to implement same in Android.
The application is developed in Asp.net and C#
To authenticate a user on android login, I have created a login API which takes username and password in the query string and in return the API return Json Data From That User.
example : www.yourdomain.com/authenticateuser.aspx?username=xxxx&pas=YYYYY
But I doubt whether its safe to send the data via query string.
Can anybody suggest a better possible way where it is not mandatory to send the data in Query String.
You can use Soap based web-service. I created a demo to consume Soap Web-service without KSoap Library.
Ref Link: SoapWithoutKSoap
You can use KSoap Library to create complex Soap Data Request.
I hope this can help you.
C# Web-Service: Demo and Demo1
UPDATE
Web Service Link will be something like this : http://123.456.789.012/Abhan/Abhan.asmx?op=JustTest (This is not working as I modified the IP Address)
In Browser, method name and passing parameter(s) information will be like something as attached image.
Thanks.
I'm using C# web services to autenticate users, send report data and get app updates.
You can get some exmaples in the web (C#):
http://msdn.microsoft.com/en-us/library/8wbhsy70%28v=vs.90%29.aspx
and ksoap2 for Android:
http://code.google.com/p/ksoap2-android/
But I also bought a SSL certificate to use https...

using web service to get a file

I have a zip file and I have client application I need to send my files to web service how I can implement it easily ?
web service should have ability to store them on the server.
You can either do it the easy way just by passing an array of bytes to your web service like this or you can use a more complex way and send it as a FileStream (I have never tried the second way) like this.

Categories

Resources