Marcus Mac Innes' Blog

Irish Views on .NET, C# and of course "Services"...
posts - 48, comments - 532, trackbacks - 66

How to Configure WSE 2.0 Services Behind a NAT Router.

When I recently put a bunch of Microsoft Web Service Enhancements (WSE 2.0) services to the test across an Internet based connection I was in for a surprise…

I hadn’t counted on the problem of trying to configure WSE to work behind our “Gateway to the Internet”, the Network Address Translation (NAT) router!

Our office LAN sits behind a router/firewall which ‘protects’ it from the 2Mbit broadband Internet pipe. All but the necessary TCP/IP ports are blocked and all workstation machines are running Windows XP Service Pack 2 with the firewall enabled.

The preliminaries to getting it all running include the usual:

1) Opening up the relevant TCP/IP port on the firewall. (The default port for the soap.tcp transport is 8081)

2) NAT mapping of the router port 8081 to the test server or workstation’s port 8081.

3) If using Windows XP SP2 as a test machine, then add the service host application to the list program exceptions for incoming network connections in Windows Firewall.

And this is where it gets a little tricky…

A problem arises from the fact that the external IP address belongs to the router and not the machine which is hosting the service. This machine hosting the service has its own internal IP address which is not visible from the outside.

But WSE doesn’t allow binding a SoapService to an IP address that is not local to the machine. i.e. you cannot bind to the router’s IP address, you can only bind to a address such as localhost.

If you try, you get the following error: WSE813: The following transport address could not be mapped to a local network interface: soap.tcp://<RouterIPAddress>.

Furthermore if you bind your SoapService to localhost then all incoming network connections that originate from the local network are received by WSE and are served correctly. Incoming connections that originate from outside the firewall however are addressed to the router. Since the router (using NAT) is configured to map these incoming connections to the internal machine which is hosting the service, the message is indeed routed to the correct host application…

But upon receiving these external messages WSE rejects the request and reports “Destination Unreachable” back to the client. The reason for this is simple, WSE uses WS-Addressing and the wsa:To address is not referencing this machine, its referencing an endpoint on the router.

After some investigation, trial and error and finally common sense, the answer was quite simple, employ the use of WS-Addressing’s wsa:Via  as follows.

Register the SoapService using a logical name such as “MyService” and a Via: specifying the IP address of the machine hosting the service:

MyService service = new MyService();
Uri logical = new Uri("urn:MyService");
Uri via = new Uri("soap.tcp://<ServiceHostIPAddress>");
EndpointReference epr = new EndpointReference(logical, via);
SoapReceivers.Add(epr, service);

On the client you do something similar except specify the router’s IP address:

public class MyClient : SoapClient {
    public MyClient() : base(
        new EndpointReference(
        new Uri("urn:MyService"),
        new Uri("soap.tcp://<RouterIPAddress>")) {}
}

Easy as that!

posted on Sunday, September 26, 2004 4:32 PM

Feedback

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

thanks, I'd never have found it by myself
10/16/2004 12:21 AM | Julian Lawrence

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

Marcus,
can I assume that you don't have a local DNS server behind the NAT Router?
Julian
10/30/2004 12:45 AM | Julian Lawrence

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

Hi Julian,

We are running a Windows 2003 Server Domain Controller with DNS and DHCP enabled. However from outside the firewall, only the gateway's domain name is resolved by the ISP. From inside the firewall, the local DNS resolves all local machine names.

All that said, from what I recall, we only used IP Addresses in our testing. Let me know if you need any specific help in getting it configured.

Marcus
10/30/2004 8:42 AM | Marcus Mac Innes

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

Thanks for great hint! Just need a small clarification:
1. Where exactly do you register the SoapService, i.e. constructor, etc.?
2. After declaring the router endpoint on the client-side, how do I link it to the web service proxy object.

More details will really add value and completeness to your great findings.

Thanks in advance!
11/15/2004 11:43 PM | TD

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

TD,

1) The SOAP service can be registered anywhere you like. But WSE won't start listening for messages on the port until it has been registered. Normally services that are listening on TCP channels are hosted in a Windows Service and if that's the case, you could put the registration in the service's OnStart method like:

protected override void OnStart(string[] args)
{
MyService service = new MyService();
Uri logical = new Uri("urn:MyService");
Uri via = new Uri("soap.tcp://<ServiceHostIPAddress>");
EndpointReference epr = new EndpointReference(logical, via);
SoapReceivers.Add(epr, service);
}

2) With the above example, you don't have a proxy object on the Client side... You are effectively creating your own proxy object by inheriting from SoapClient:

In the above class "MyClient" you would have methods like:

[SoapMethod("AddItem")]
public SoapEnvelope AddItem(SoapEnvelope request) {
return base.SendRequestResponse("AddItem", request);
}

Where AddItem corresponds to the desired Action.

Marcus
11/15/2004 11:54 PM | Marcus Mac Innes

# re:How to Configure WSE 2.0 Services Behind a NAT Router.

^_~,pretty good!18showsseeoo
4/26/2005 9:40 AM | 万能试验机

# re:How to Configure WSE 2.0 Services Behind a NAT Router.

^_~,pretty good!csharpsseeoo
5/20/2005 7:03 AM | 充气式电容器

# re:How to Configure WSE 2.0 Services Behind a NAT Router.

How to Configure WSE 2.0 Services Behind a NAT Router.ooeess
7/17/2005 9:37 AM | 红外热像仪

# re: How to Configure WSE 2.0 Services Behind a NAT Router.


http://forum.vatan.tc/bilgisayar-ve-internet-dunyasi-b144.0/
http://forum.vatan.tc/pc-konulari-ve-yardim-b145.0/
http://forum.vatan.tc/windows-isletim-sistemleri-b168.0/
http://forum.vatan.tc/linux-isletim-sistemleri-b169.0/
http://forum.vatan.tc/program-anlatimlari-b146.0/
http://forum.vatan.tc/cesitli-programlar-b147.0/
http://forum.vatan.tc/playerlar-ve-donusturuculer-b149.0/
http://forum.vatan.tc/guvenlik-ve-antivirus-programlari-b148.0/
http://forum.vatan.tc/messenger-programlari-b150.0/
http://forum.vatan.tc/program-istekleri-b151.0/
http://forum.vatan.tc/temel-programlama-ve-algoritma-b153.0/
http://forum.vatan.tc/c-c-c-b156.0/
http://forum.vatan.tc/visual-basic-net-b157.0/
http://forum.vatan.tc/java-jdk-ve-jsp-b158.0/
http://forum.vatan.tc/delphi-delphinet-b159.0/
http://forum.vatan.tc/pascal-b196.0/
http://forum.vatan.tc/script-dilleri-b154.0/
http://forum.vatan.tc/javascript-b160.0/
http://forum.vatan.tc/php-b161.0/
http://forum.vatan.tc/asp-aspnet-b162.0/
http://forum.vatan.tc/mirc-scripting-b163.0/
http://forum.vatan.tc/web-tasarim-grafik-ve-araclari-b155.0/
http://forum.vatan.tc/frontpage-html-dhtml-xml-css-ve-benzerleri-b164.0/
http://forum.vatan.tc/photoshop-paintshop-imageready-vb-b165.0/
http://forum.vatan.tc/macromedia-merkezi-flash-dreamweaver-fireworks-vs-b166.0/
http://forum.vatan.tc/icon-font-template-vb-arsivi-b167.0/

http://www.vatan.tc
http://www.internet7.org
http://www.e-sorgulama.com
http://www.forumitiraf.com
http://www.islamiruyatabirleri.com
http://forum.vatan.tc/sitemaps-0.html
http://forum.vatan.tc/sitemaps-1.html
http://forum.vatan.tc/sitemaps-2.html
http://forum.vatan.tc/sitemaps-3.html
http://forum.vatan.tc/sitemaps-4.html
http://forum.vatan.tc/sitemaps-5.html
http://forum.vatan.tc/sitemaps-6.html
http://forum.vatan.tc/sitemaps-7.html
http://forum.vatan.tc/sitemaps-8.html
http://forum.vatan.tc/sitemaps-9.html
http://forum.vatan.tc/sitemaps-10.html
http://forum.vatan.tc/sitemaps-11.html
http://forum.vatan.tc/sitemaps-12.html
http://forum.vatan.tc/sitemaps-13.html
http://forum.vatan.tc/sitemaps-14.html
http://forum.vatan.tc/sitemaps-15.html
http://forum.vatan.tc/sitemaps-16.html
http://forum.vatan.tc/sitemaps-17.html
http://forum.vatan.tc/sitemaps-18.html
http://forum.vatan.tc/sitemaps-19.html
http://forum.vatan.tc/sitemaps-20.html


4/10/2008 10:55 AM | forum

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

thank you

http://www.Aylak.com
http://Sinema.Aylak.com
http://www.Eziyetsiz.com
http://www.Felekten.com">http://www.Felekten.com
http://www.Evcilminikler.com
http://www.Felekten.com">http://www.Felekten.com
http://www.duyurun.com
http://www.Netarac.com
http://www.Aylak.net
http://oyun.Aylak.com
http://www.prifri.com
http://kopek.evcilminikler.com
http://petshop.evcilminikler.com
http://sohbet.evcilminikler.com
http://kedi.evcilminikler.com
http://balik.Evcilminikler.com
http://surungen.evcilminikler.com
http://sohbet.aylak.net
http://haber.aylak.net
http://ekart.aylak.net
http://mail.aylak.net
http://www.bilgiturk.org
http://forum.evcilminikler.com
http://hosting.Eziyetsiz.com">http://hosting.Eziyetsiz.com
http://domain.Eziyetsiz.com
http://whois.Eziyetsiz.com
http://sunucu.Eziyetsiz.com
http://yazilim.Eziyetsiz.com
http://software.Eziyetsiz.com
http://design.Eziyetsiz.com
http://dizayn.Eziyetsiz.com
http://eticaret.Eziyetsiz.com
http://hosting.Eziyetsiz.com">http://hosting.Eziyetsiz.com
http://tasarim.Eziyetsiz.com
http://servers.Eziyetsiz.com
http://www.kitabet.com
http://www.romanticapart.com
http://www.tatilhotel.net
http://kopek.evcilminikler.com/irk/rottweiler/
7/12/2008 4:33 AM | Oyun

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

Thanks you very good !.
10/22/2008 2:48 PM | cinsel urunler

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

I'm guessing the only way to do this in Javascript would be to use the onresize event, and then using the resizeTo method to attempt to keep the window at the size you want?
11/16/2008 4:25 PM | Estetik

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

thanks very.
11/21/2008 2:40 PM | arkadas

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

thanks very.
12/6/2008 12:11 AM | chat

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

# re: How to Configure WSE 2.0 Services Behind a NAT Router.
thanks very.
12/6/2008 12:11 AM | sex shop
3/5/2009 2:35 PM | sexshopum.com

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

# re: How to Configure WSE 2.0 Services Behind a NAT Router.
# re: How to Configure WSE 2.0 Services Behind a NAT Router.
thanks very.
12/6/2008 12:11 AM | penis büyütücü hap
3/5/2009 2:37 PM | penisbuyutuculeri.com

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

# re: How to Configure WSE 2.0 Services Behind a NAT Router.
# re: How to Configure WSE 2.0 Services Behind a NAT Router.
# re: How to Configure WSE 2.0 Services Behind a NAT Router.
thanks very.
12/6/2008 12:11 AM | sexshop
3/5/2009 2:39 PM | sexshopevim.com

# re: How to Configure WSE 2.0 Services Behind a NAT Router.

penis büyütücü hap, penis büyütücüler, penis büyütücü
http://www.sexshopum.com
http://www.sexshopevim.com
http://www.penisbuyutuculeri.com
3/5/2009 4:14 PM | penis büyütücü hap
Post a new comment about this topic
Title  
Name  
Url

Comments   
Enter the code you see: