NTBuddy
NTBuddy

Reputation: 299

Silver and WCF Service Behind Firewall

I have a Silverlight 4.0 (ASP.Net 4.0) application on our website for our customers once they authenticate. The program loads fine but can't talk to the WCF service created. Internally everything works great.

The Silverlight application is hosted on IIS 7.5 with an internal IP of 10.1.1.8 with teh firewall redirecting the real world application to the internal ip address. This part works fine. The WCF service is on IP 10.1.1.10 and is the same virtual machine just with different IP addresses. The database server can be pinged without a problem as well.

http://www.ntbuddy.com/images/stackoverflow/SilverlightWcf1.png

The Service Reference in the Service References is "http://10.1.1.10/ServiceReference/Common.svc" for the routine below.

Below is the simplest of routines where I request from the Wcf a number back for an auto-number routine.

Works only for internal users (Silverlight)

private void BtnAutoNumberClick(object sender, RoutedEventArgs e)
{
   AutoNumber("AUTO");
}

private void AutoNumber(string autoNumber)
{
   var objResult = new CommonClient();
   objResult.GetAutoNumberCompleted += new EventHandler<GetAutoNumberCompletedEventArgs>(LoadResultsAutoNumber);
   objResult.GetAutoNumberAsync(autoNumber, 4, autoNumber);
}

void LoadResultsAutoNumber(object sender, GetAutoNumberCompletedEventArgs e)
{
   txtOrderNumber.Text = string.Format("{0}", e.Result.AutoNumber);
}

What do I need to change in my Silverlight application to make it work for the external user as well as the internal user? I want to avoid making the Wcf service being exposed but will if that's what is required.

Upvotes: 1

Views: 404

Answers (2)

NTBuddy
NTBuddy

Reputation: 299

Okay, this took a total of six days of reading and studying for it to "click in". I figured Silverlight would be totally easy, which for the most part it is as I've been writing ASP.Net/WinForm applications for years. Many times we look at a problem and look and look and for the life of us we can't get the solution as we're to focused on the single problem and don't step back and look at the overall picture. It took "Shiraz Bhaiji" answering about 10 series IP addresses being internal only. I knew this but was the magical key to releasing my mind from its confusion. I drew everything up on my whiteboard and put in routing tables and then smacked myself on the back of the head at the obvious solution (e.g. an outside visitor can't see my internal 10 series network).

In a nutshell, this is what I've learned on my first Silverlight application:

Silverlight runs on the CLIENT, not the server (e.g. ASP.Net). I was testing all of my Silverlight against an ASP.Net application that had been running perfectly for over a year. The Silverlight application runs on the server and I couldn't for the life of me figure out why my WCF service worked for ASP.Net but not Silverlight. Being the Silverlight application is downloaded to the client they will only see the WCF service if it's behind a firewall either (1) you open up your firewall to allow it to have access or (2) move the service to the internet (make certain to include the necessary security). I'm sure there are more ways even a combination of 1 and 2.

I chose option #1 to move it to be a dedicated and visible service. I made it easily available and on an alternate port with the security within the service. The firewall redirects to my internal site and everything is well. So if you're using Silverlight make certain that when you test internally you also start and test externally, if you're going to expose it externally, as well.

Upvotes: 1

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65431

ip addresses that start with 10 are internal addresses, you will not be able to access this address from outside the firewall.

http://en.wikipedia.org/wiki/IP_address

If you look at the table marked "IANA-reserved private IPv4 network ranges"

You need to expose your service using an external ip address.

Upvotes: 1

Related Questions