application to receive the request c# - c#

Currently I have created a method in webapi to send a request by uploading the x509 certificate.
Now i need to write and application receive this request sent by the api and validate the certificate, could you please let me know how this must be done? I'm preety new to this.

You will likely want to use a web service as your receiver. It would impractical to explain how to create a web service as there are a tremendous amount of examples readily available by doing a quick search on google for C# Web Service or C# RESTful Web Service example.
Here are a couple of results to get you started:
HOW TO: Write a Simple Web Service by Using Visual C# .NET
Restful webservices in C#
If you work through one or two example projects and you run into a problem that you can't figure out, come back and post a new question. As it is, this question is a bit vague, so this will probably be about as specific of an answer as you're going to get.

Related

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.

WCF send xml to Web Service and receive message

Please tell me, can i accomplished something like..
Some company has created CRM, this CRM provides some Web Services. I can communicate with this services via XML. So my question is can i create Windows Services with WCF which will be send some request ( every hour ) to Web Service and receive data from this web services.
Example:
At 9am, 10 am... WCF has sent request ( XML ) to Web Service:Hey CRM how many users you have?
Web Service received a message and response via XML: I got 10 users.
WCF received message: I got 10 users... and did something with it.
Please for some help. Articles, code sample, or key words what should i look for.
nothing in your question indicates the need for WCF, it sounds like all you need to do is create a SOAP reference (web reference) to this CRM Web Service and call it every hour. This could be a console app or any app for that matter.
If the provided web services are standard, WCF should be able to communicate with them.
Add a service reference, specify the URL, and if discovery (WSDL) is available, Visual Studio will allow you to quickly generate a proxy class that makes using the server very easy.
Scheduling the requests every hour is not related to wcf, use task scheduler or a manual solution for that.

Consuming IIS-hosted WCF Service from Linux Web Application

I was tasked at work to create a web application (viewable in Firefox on Linux!) that displays results in a tabular format using data exposed by a WCF service (written in C#) hosted on a separate Windows 7 machine on the same network. Rather than returning formatted HTML, the WCF service returns structs and it will be up to the client application to take these objects, pull out the data, and format it.
Unfortunately, it has been a couple years since I have worked with any sort of web technologies. What is the best approach to solve this problem? Is there anything more current than REST/AJAX/JSON/jQuery technologies? If anyone can point out some helpful and current resources on the proper way to accomplish this, it would be most appreciated.
Use a SOAP framework to consume the WCF service. Configure WCF to use SOAP (one of the HTTP-bindings).
Webservices are easy to consume these days thanks to a standard RPC format (SOAP) and libraries supporting it. You can surely find a SOAP client for any language you are proficient in.
Checking back in here to report my own solution for this problem. I ended up going a bit of a different route that produced the simplest solution for the situation. Instead of consuming any services on the Linux side, I simply made an ASP.NET website on the Windows/IIS side (where it is easy to consume the WCF services right from Visual Studio), and then just render the website on the Linux side via the URL in a Firefox browser. For me, that fulfilled the customer requirements and was perfect, although this may not be the best approach for others that need to work with or manipulate the data in some way.

Returning JSON from WCF after POST in Android

I just started coding for my android application and I am unsure of how I should start coding.
If I want to do lets say a login in my android application. How should i start?
Is it possible if I do it in this way:
Send POST to my WebService > Web Service Validates credentials > Return user information
Please help!
Yes your process is correct.
If you have simple needs like what you describe using the default serializer should be enough, just specify:
WebMessageFormat.Json
Later if you need a full fledged JSON library use Json.NET
A small tutorial to get you started (it uses a similar use-case): http://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec
Do not forget to use authentication over HTTPS only...

adding a WCF to existing website or have a new service?

I am a total newbie to the WCF world. I have an ASP.net (v4) website running on our dedicated windows 2008 server box. I'll refer to the website as, webisteA.com
I'm creating a new website, websiteB.com.au and I'd like to expose the functionality in WebsiteA.com to the new site. Things like logging in, registering in the database etc.
I think the best way to do this is to create a WCF service which sits in WebsiteA.com - but I am struggling to find any tutorials on how to do this. There are lots about creating a new project, but not that many about adding a WCF service to existing websites.
Is this the best way to do it? In the future I'd also like to use the service for mobile apps in the future too - not sure if that will make a difference.
OR - do I create a new service in a new app which is totally seperate to websiteA.com and websiteB.com and host this as website0.com and expose the database via that?
The questions I don't have answers for are...
is it restful? Do I use XML or JSON?
Baiscally, I want to be able to use it like an API - for example, saying "show me all the members who meet criteria X".
Thanks for any information.
ps) I have visual studio express 2010 c# (and a trial of studio pro)
You can certainly include WCF within the website A project - but have you considered the ASP.NET Web API? I haven't used it yet - but did use the earlier WCF Web API which spawned it.
Neat features include Content Negotiation (if the client asks for XML the API sends XML. If it asks for JSON is gets JSON) and a lot less config cruft (WCF web.configs are dreadful and completely overcomplicated IMO)
It's probably a lot easier to make a RESTy API with the ASP.NET Web API than with standard WCF.
A great open-source .NET solution is NancyFX which is really worth a look too.

Categories

Resources