iOS consume WCF Service using HTTPS - ios

I'm developing a iPad application that will consume a WCF Service HTTPS (using soap probably).
I used NSURLConnection on iPad to connect to HTTP web service and worked fine. But the WCF Service will use HTTPS.
The WCF as some different configuration (eg. security mode: Transport,Message and TransportWithMessageCredential).
Is there any limitation on iPad to consume a WCF service using HTTPS? What is the best way?

You can use NSURLConnection itself. If you want to handle the security credentials while connecting to the server you have to look into the below methods,
- (BOOL)connection:(NSURLConnection *)conn canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
- (void)connection:(NSURLConnection *)conn didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
The below sample project from Apple will help you,
http://developer.apple.com/library/ios/#samplecode/AdvancedURLConnections/Introduction/Intro.html

Related

Best way to secure a WCF service when used from an asp.net mvc application

I have a multilayer asp.net mvc application consisting of the following levels:
Database (with stored procedures, views and tables)
WCF service (containing business logic and connection to the database through Entity Framework)
Asp.net mvc application communicating with the WCF service and generating html
Browser
The end-users are authenticated in the asp.net mvc layer using Identity 2.0.
The web server is the only client for the WCF service.
Are there any best-practices for this scenario?
The web server and the WCF service might be running in different locations so we cannot use the intranet protocols.
Since we control both the web server and the WCF service we know that the communication will be point-to-point. This means we can use transport security to avoid the extra overhead with message security.
According to this, Improving Web Services Security: Scenarios and Implementation Guidance for WCF, there are two choices for transport security over internet:
Basic authentication with basicHttpBinding
Certificate authentication with wsHttpBinding
Which one would be best suited to this scenario where there basically is only one client for the WCF service?
Due to the stateless nature of http for each new request to the web server a new service-proxy is instantiated.
Is there a way to cache the authentication info from the WCF service on the calling web server to better performance?
You can set up certificate authentication between your WCF and MVC servers using BasicHTTPBinding ... I've done it. But I'm not sure why you use BasicHTTPBinding when, from your description, all the backend services (WCF and MVC) are Microsoft based.
BasicHTTPBinding is a generic WCF protocol that will accept any properly formatted HTTP request (Gets/Post), whether the request comes from a Windows machine or the JAVA/PHP world. It's also, as you say, stateless. That makes BasicHTTPBinding good for interop situations, but more complex (than say wsHTTPBinding) when setting communication between two MS-centric systems.
By default, for instance, NONE is the default encryption for BasicHttpBinding. Adding Transport takes programming and lot of trial and error to get running, from my experience. BasicHttpBinding, also, doesn't support transactions or sessions while WSHttpBinding does. So, based on your description, WSHttpBinding will be simpler and easier to setup and maintain in the long run. But you might also consider NetTCPBinding since you're going server-to-server.
Below you'll find a great MS site explaining all the different WCF protocols, including to pros and cons of each approach.
http://msdn.microsoft.com/en-us/library/ms730879.aspx

How to invoke SOAP web service via AFNetworking and NSUrlSession

I have followed this tutorial on how to get data via web service.
And in there author used PHP and REST to access service like:
NSString *string = [NSString stringWithFormat:#"%#weather.php?format=json", BaseURLString];
And I am having trouble to use this on .NET SOAP (.asmx) web service like this one.
How I can use NSUrlSession and AFNetworking to send/receive data to/from asmx web service?
I have a problem as I don't know how to form a request to some method on this web service and pass parameters. It's a lot different compared to SOAP. It can be that I am stupid but can't figure this alone :(
Just starting into this now. I found this:
https://developer.apple.com/library/mac/documentation/cocoa/conceptual/urlloadingsystem/Articles/UsingNSURLSession.html#//apple_ref/doc/uid/TP40013509-SW1
stating this: Only HTTP and HTTPS protocols are supported (no custom protocols).
Which leaves me more than a little bit concerned.
Update: I'm receiving SOAP responses - even though it is technically a custom protocol.

Calling WCF callback service from a ASP.NET web app hosted in IIS

I have to develop a WCF callback service which will be accessed by the ASP.Net web application hosted in IIS or public internet. In this implementation clients should keep getting the updates from the service, so I thought of using WsDualhttpBinding, but I found few disadvantages of WCF callback service over internet.
How to use a WCF Dual Service over the internet? Any one please suggest any sample application for this?

Consume Secured web service in Asp.Net MVC

I'm working on asp.net mvc
I want to consume secured web service in my project
In previous I can consume unsecured web service (asmx) by calling wsdl to create proxy class ,now
I tried to create proxy class for the service by using wsdl.exe by using the following formula
Wsdl /language:language /protocol:protocol /namespace:myNameSpace /out:filename /username:username /password:password /domain:domain
But I had the following error
Error: There was an error processing 'https:// .asmx?wsdl'.
- There was an error downloading 'https:// .asmx?wsdl'
- Unable to connect to the remote server
- A socket operation was attempted to an unreachable network ??.???.???.??:???
Can you tell me how can I consume secured web service in my project
Yara
I dont know what sort of service you are talking about but I suspect you are Adding it as a Service/Web reference. If thats the case then assuming its called WebService1 and that the security you are talking about it basic authentication then:
WebService1 svc = new WebService1();
svc.AuthenticationHeaderValue = new WebService1.AuthenticationHeader();
svc.AuthenticationHeaderValue.UserName = "username";
svc.AuthenticationHeaderValue.Password = "password";
Try that. As I said I dont have much info on what you are trying to do so its a guess.
First of all it doesn't matter you are in MVC or any other technology.
If you can call https webservice using simple code, it will do wonders for you.
So first try calling simple HTTPS web service, google and play around it.
For learning purpose and to gain more knowledge, check these links
How to call HTTPS web service method from a .net console application?
Calling a https web service (C#)
http://support.microsoft.com/kb/901183

Can you connect to ASP.net soap service using Kerberos authentication using MonoTouch?

I am trying to connect to an ASP.net soap service using Kerberos authentication using MonoTouch but it does not support WSE extensions. it returns a 401 auth failure.
Was planning on doing something like this
http://www.15seconds.com/issue/040603.htm
Is there a way to use WebServicesClientProtocol class in MonoTouch or any alternative way to do Kerberos authentication using MT?
Mono itself does not support Kerberos and all the web services code of MonoTouch is based on it.
FWIW Web Service Enhancement is very old and was never supported (2.0) by Mono. You should look at WCF and the (Silverlight-based) subset that MonoTouch support.

Resources