Communicating via https within a c# web service - c#

I've got a client who requires a secure transaction made over HTTPS. They do not provide any web services to consume, so instead they have a simple post over HTTPS with SSL. I have two applications that need to utilize this service, one is a website, one is an iOS app, so I figured to save some time and effort, I would write a proxy web service that both of these applications would use to pass data back and forth between the client's system.
So I have the web service sitting on a server, with an exposed web method which is being consumed by the application. The variables are in the method, can someone please help me with sending that data via https POST to the required URL? I've never done anything like this before and I'm a bit lost. The web service is programmed in C#.

If you are using .NET 4.5, you can use the System.Net.Http.HttpClient
http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx
or, System.Net.HttpWebRequest if you are using older version of the framework.
Here's an example
HttpWebRequest with https in C#

Related

Using SignalR on non-web applications

I would like to implement SignalR into one of my WPF applications for its real-time capabilities to communicate between client and server. However, everything I have read points to SignalR only being used on web browsers. Would it be possible to use SignalR in my application that does not include any web browsers (without adding a WebBrowser element to my project displays)? To try to clarify, I would like to use all the perks of SignalR such that a couple displays in my application update their data in real time, with no web browsers. If so, what would this look like? Thanks!
Yes, SignalR has .NET, Java, and JavaScript clients. A web browser isn't necessary. Technically anything that knows one of the transport protocols that SignalR provides (such as web sockets) could have a client written for it.

Login to ASP .NET MVC website under HTTPS using Windows Service

I have some administrative methods under ASP .NET MVC website that is under https.
So it looks like
https://mysite.com/cms
and there are some actions like CheckUsers
My question is
Can we develop some external Windows Service to sign in to that website and execute some methods?
I mean how to do it technically (sign in and call methods?)
So tha chain is like that
Windows Service <---> call method CheckUsers() under
https://mysite.com/cms <---> other https://site2.com
I just need to automate execution of some methods and do it periodically with Windows Service.
It is a question of possible communication between Windows Service and ASP .NET MVC.
Any clue?
We've been using http://htmlunit.sourceforge.net/ for sending requests to third-party web sites. It allows you to send requests, receive response/status code/etc. Basically, its a small GUI-less browser which evaluates HTMKL, JavaScript, etc.
(it's a Java lib, so you could either google for a .Net port or use a converter to convert Java assembly into .Net assembly - see http://blog.stevensanderson.com/2010/03/30/using-htmlunit-on-net-for-headless-browser-automation/ for guidance. We've used the convertion approach).
If your requirements are less sophisticated, you can just use HttpClient or WebClient to send simple requests and parse responses manually.
NB: in case you're going to parse HTML manually, I suggest that you use Html Afgility Pack: this is the right way to parse HTML(mainly, because it "fixes" invalid tags, errors, etc).

Create C# SOAP API Consumable by other Languages

I've been trying to find a tutorial on here, MSDN, and Google on how to implement my own SOAP API. I have an application written in C# that I want to be consumable by PHP so that calls from the web can interact with the application. How do I generate and tie a WSDL file to my application so that it can be communicated with over SOAP calls? Any suggestions?
I think for this you just need to create WCF service in .net that will allow you to consume server from any language.
Create an ASP.Net Web Services .wsdl file to communicate with the various applications. Host the Web Service on windows IIS server and configure the ports accordingly, then you can access the endpoints to whcih ever application you are using, using the address and the web method name.

Cross server webservice using ajax

Hi stackoverflow users.
My server setup is the following:
A webserver with access on http/80 running www.domain.com
A app server with access to the internal network (db etc.) running a webservice
I have this simple little server setup problem.
Now I want to call my webservice from a ajax script from a website on my webserver. But since my application server does not have access to the internet this will (in my mind) not be possible since the javascript (running in the end-users browser) shoud have access to that webservice.
I came up with the solution by inventing a webservice on the webserver calling the webservice on my application server, but thats a odd solution, does any of you have a idea how to solve this?
I don't think you can do this. You will have to provide some thing on WebServer using which end user can access your App Server.
You have multiple options for this
PageMethods
Web Services on WebServer which will relay ajax calls to the App Server
Hope this info helps you.
If I understand correctly, you are just just using a webservice as a proxy through some network firewalls. There are tools that will do this for you, however, if you are running a simple service, then I don't see a problem with your setup.
One such tool for IIS is Application Request Routing

securing wcf services from specific sources

I am using wcf services for interaction between my javascript files and server side.
I am concerened about security around this as anyone can call these services via an application, firebug etc.
So I want to secure my web services to only be accessible from specified sources, for example the javascript files on my site - ie. the main function why I have wcf services.
I am running on the .net 3.5 framework in a c# web application.
Could anyone assist my securing my wcf services as outlined above?
If this is a combination of javascript and server side , you can probably generate a Key from the server side and store it in the javascript variable and pass again to the WCF webservices.
Kobe's answer of generated request keys is definitely one possible way. Given that your services are running on the same machine as your UI code, another way to limit access would be to set them up as regular services and not Web Services. That is of course assuming you don't need them to be Web Services.
Check out the cool work that the WCF team has done/ is doing with jQuery and WCF.

Categories

Resources