Calling External Web Services from – Part II: Opening your web service to the internet

Part I: Hosting your web service
Part II: Opening your web service to the internet
Part III: Building an Apex class that calls your web service

I have to be honest – I did not know how to do this. Having always programmed in an enterprise environment, I never gave it a thought on hosting something that is open to the internet. Fine, everybody can’t know everything, right ? Anyways, I figured there would be others as ignorant as I am (was :)), so here’s step-by-step instructions on exposing your webservice to  the internet.

  • Disclaimer – the below description is for a specific setup – where you are on a home computer with a wireless router. Be prepared to adjust the process if your setup is different.
  • First, make sure you do this on your home computer, or a place where you have full control over the network setup, environment etc.
  • We will be using port forwarding to open up the web service hosted on the IIS on your machine to the internet. To understand what is port forwarding, start by looking at the diagram below. Your home computer is actually hosted behind a few things – firewall, modem, maybe a wireless router.
  • This ensures that nothing on the internet can directly connect to your computer. It will always have to go through the modem, and the firewall. If any malicious attempt is made, the firewall will block it. The exact details are much more sophisticated than this, but this much suffices for what we are trying to do.


  • This setup also affects the IP address of your computer. Open command prompt (Start->{type cmd}), and run “ipconfig”. Notice your IP Address - it will be something like This is not a real IP address on the internet – instead, it is the “internal” IP address assigned to your computer by your modem.
  • So what is your real IP address ? Go to – this will show your real IP address. I found mine- it was This again is a temporary IP address – the internet service provider can switch it at any time.


  • Given that the modem is our “face” to the internet, any request that comes to the IP Address is routed to my modem. The modem may choose to either discard the request, OR, it may choose to forward the request to specific devices connected to it.
  • This is where port forwarding comes in – we basically “tell” the modem/router to forward any requests that come in from the internet on a specific port, to our computer. If we turn this on for port 80, which is used by web services, it means that any incoming web service call will be forwarded to our computer.
  • Enabling port forwarding is different for each setup, so I will walk you through what I did, and leave it to you to fill in the gaps for your particular network setup. First, I opened the administration page for my wireless router- this can be usually accessed by using the first 3 digits of your IP address + 1. For e.g., in my case, since my computer’s IP was, I opened my wireless router admin screen by visiting in the browser.
  • It may ask you for username/password – username is usually “admin”, you will need to know the password here – I did not know of any other way around it.
  • Once you are logged in, the screen looks like this for me:-


  • Next, I went to the “Advanced” tab –> “Advanced Settings” –> Port forwarding”. Here I configured it forward all HTTP requests (port 80) to my computer. This is how my setup looks like -


  • That’s it, all incoming HTTP requests will be forwarded to your computer now. However, we’re not done yet – these incoming requests will be blocked by your computer’s firewall. We need to open port 80 on the firewall as well.
  • Open Windows Firewall configuration - If you are on Windows 7, go to Control Panel->System & Security->Windows Firewall. From the left hand menu, choose “Allow a program or feature through Windows firewall”.


  • In the list of services that comes up, go to the last one (World Wide Web Services (HTTP)), and check both the private and public checkboxes.


  • Now we’re done – your web service is now callable from the internet.
  • To test this, visit, and put your web service URL. Your web service URL is - http://{your ip address}/MyWebService/Service1.asmx. For e.g., my web service IP address is -
  • So there you go, your web service should now be accessible from the internet. It is also now ready to be called by Salesforce. In my next post, we will go over the basics of calling this web service from


  1. Published website on IIS and able to test it using localhost but on site it gives navigation error

  2. You don't have port-forwarding enabled on your router. The site is probably hitting your IP address (that is, your modem), but you need to configure it to forward any website requests (on port 80), to your internal IP Address.

    Go through the steps for port forwarding again, and you should be able to get it to work.