Deploy WCF service on IIS that's visible from public IP - c#

I've managed to get my WCF service working on IIS express and IIS locally via localhost. I was wondering how I can deploy the service so that it can be accessed outside my network i.e http: // public ip. I've done a lot of digging around and can't seem to find the right answer.
I've tried setting the IP bindings on IIS to my public IP but I get 'Bad request - invalid hostname'.
I have opened all necessary ports and host my own apache server which is accessible outside my network, so I know that the ports side of things is fine. I'm just having issues with the server hosting (IIS).
Any ideas how this can be achieved?

Related

WCF communication on Http

I have a WCF service which works fine when accessed internally. The WCF link is
.
I requested the network team at our organization to expose this WCF to outside world since public websites will access this WCF. I gave the network team DNS as somewebsite.com and IP address of the server on which WCF is hosted.
After getting the confirmation from Network team (they use Juniper network ) that they have made the required settings to make the WCF available to outside world I tested it as an external user.
If I type in http://somewebsite.com/LookUp.svc on address bar I get http 404 page not found error. However if I replace http with httpS as then I see the WCF information. To further test it , I added a simple html file to the root of the website and opened as
http://somewebsite.com/test.html. The Test.html does not open when http is used. However it I use httpS as then Test.html page is displayed to outside users.
The WCF is hosted to windows 2008 R2 and is communicating over port 80 and I have also added the site binding as somewebsite.com with Type as Http and port as 80.
Any idea why WCF caanot be accseed over http ?. I want it to be accessed over http only ?. The WCF uses basicHttpBinding
Is the setting wrong on server on which WCF is hosted ?
Any suggestion is greatly appreciated..
If the service worked before over http before your network guys opened the firewalls I would suggest that they have only enabled the firewall for https traffic.
Sounds like a firewall/routing problem to me...
HTH

Cannot access Web Service (asmx) from host machine (running IIS 6)

I have simple web service (asmx) running on my PC using port 7778.
I've assigned the app pool (v2), port forwarded 7778 on my router to resolve to my local IP address (192.168.1.2) that I've set up manually (static local ip address). I've also used NoIP's service for DNS and this is checking if my non static real Ip address changes.
when I try to connect to:
http://mynoipdnsname.no-ip.biz:7778/Service1.asmx from any computer outside my local network
It's all working,
using:
localhost:7778/Service1.asmx or
192.168.1.2:7778/Service1.asmx
from my local PC works fine.
The problem is that when I try:
http://mynoipdnsname.no-ip.biz:7778/Service1.asmx
from my local computer (192.168.1.2)
it's not getting the data.
I have Android app, when I try to add web service's url:
http://mynoipdnsname.no-ip.biz:7778/Service1.asmx
I get error message:
Unable to connect to the remote server No connection could be made
because the target machine actively refused it
Any ideas what I've missed?
Thanks in advance.
P.S. My windows firewall and router firewall are turned off.
Add mynoipdnsname.no-ip.biz to your hosts file or your DNS.

HttpListener not receiving remote requests, even with the firewall down and all prefixes registered

I've written a server using HttpListener that works perfectly well for requests sent from the same computer, but doesn't even receive requests sent from a remote machine. I've tried using (including registering with netsh) the following prefixes: http://*:8080/, http://+:8080/, http://localhost:8080/, and the specific IP address of the host computer followed by port 8080. (I also made sure no other applications were using 8080.) I opened up the appropriate ports in the firewall, and when that didn't work, I turned off the firewall just to see if it was a firewall issue and that also had no affect on the problem. I have no idea what to try next, please help!
Also, the machine running this web service is a Amazon Web Services Microsoft Windows Server 2008 R2 with SQL Server Express and IIS EC2 instance.
If you are using AWS free tier EC2 instance, adding the given public elastic IP as the prefixes will not work for you even after you have the local firewall port and ports in security group opened. The HTTPListener needs to be bind with the public DNS provided by AWS. Then only it will work.
For future users, the solution in more detail was to add an Inbound Custom TCP rule that included port 8080 in the 'Port range:' to a Security Group used by my EC2 instance.
thanks to #shashankaholic for pointing that out

WCF Service behind firewall – How to set up port forwarding?

I'm just getting into WCF programming. I've set up a self-hosted test web service on my work computer, which is behind a firewall; it's at http://localhost:8000/MyTestService. I can access the service page through the browser; all working fine.
Now I want to access that service from my home computer, which is on a different network. I have a dynamic dns (call it mydomain.dyndns.org) set up to point to my work router. Have tested, dyndns is pointing to the right address.
Now I have installed a test app on my home computer to connect to my web service. So I configured my NAT for forward requests on port 8000 to my work computer, on the same port number.
On my home computer I now open a browser and navigate to http://mydomain.dyndns.org:8000/MyTestService. Nothing doing.
Obviously I'm missing something really fundamental about NATs and port forwarding... but as I say, I'm kinda new at this aspect of programming, and I'd really appreciate some guidance here!
Do you see an error or an empty page? Can you check canyouseeme.org from the computer behind the firewall that the port is really open? Can you check with tools like sysinternals tcpview that the connection attempt reaches this computer and not just the router?
I had the same problem.
after a good help from this toppic. http://www.codeproject.com/Questions/140317/WCF-services-and-Windows-Firewall. My WCF Service worked well on the local LAN even with the firewall active.
But it was not accessible over the internet.
After port forwarding i could see the service description. but I couldn't use it.
This article http://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/ points me in the right direction.
The service is visible, but connections to your web server will fail because the WSDL is pointing to the non-published server name and your client won’t be able to get there.
In my case a I need to change the self hosted wcf the local endpoint to the public one.
// 1 Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://publicdomain.com:8000/GettingStarted/");
// Step 2 Create a ServiceHost instance
ServiceHost selfHostRemote = new ServiceHost(typeof(MyService), baseAddress);

"port forwarding": redirect calls to webservice at port 8081 to port 80

a colleague of mine wrote a webservice that runs on port 8081 of our Windows 2008 Server.
He uses the class ServiceHost, afaik this means its a standalone host (no IIS or ASP involvement). Note: I'm new into WCF ;)
Now there are some issues with clients behind a firewall blocking the requests to remote port 8081 of our server (where the webservice runs). The easiest solution would be: run the webservice host at port 80 ... But: there is also a Apache 2.2 webserver running on the Windows Server, hosting some websites. By default it runs on port 80.
My solution after some researching: use a virtual host to route requests to a virtual host (lets say http://webservice.[hostname]:80) to the webservice host (http://[hostname]:8081).
Is this a good idea? Can Apache handle forwards to standalone webservice hosts?
It would be nice if someone could lead me on to the right track :)
Best regards,
Niels
If your Apache server is your forward facing server and you want the requests to be forwarded to your internal service/IIS you should look at mod_proxy and configuring a reverse proxy.
The easiest solution would be to get a different IP address to run the WCF host on. Then, you could have both listening on the same port but different IP addresses.

Categories