Hi,
I have a Windows Service which is hosting a WSE web service over TCP
(WSE 2.0 SP3).
On startup, I call this code for each of the available IP addresses:
Uri address = new Uri("urn:MyService");
Uri via = new Uri("soap.tcp://<ip address>:<port>");
EndpointReference epr = new EndpointReference(address, via);
SoapReceivers.Add(epr, webService);
This way, requests can enter via any of the IPs assigned to the server.
(If there is a way to do this without specifying each IP address
seperately, I'd really love to know)
The Windows service is intended to be running 24/7, with the
possibility of new IP addresses being added at runtime. On these newly
added IP addresses, the web service must also be available.
I tried calling SoapReceivers.Add(...) for the new ip address after it
was created, but got this exception:
System.ArgumentException: WSE813: The following transport address could
not be mapped to a local network interface: soap.tcp://<new ip
address>:<port>/MyService.
Any ideas on how to solve this issue? Restarting the Windows Service
does work, but is not an option.
Thanks,
Wouter
Wouter Demuynck - 25 May 2005 15:36 GMT
With some help from .NET reflector, I found that when using the
hostname in the Uri instead of an IP address will result in
SoapTcpTransport.GetLocalIPEndPoint returning IPAddress.Any, which is
what I want. After executing the following code, the web service will
be available on all local IP addresses.
IPHostEntry hostentry = Dns.GetHostByName(Dns.GetHostName());
Uri address = new Uri("urn:MyService");
Uri via = new Uri(String.Format("soap.tcp://{0}:<port>",
hostEntry.HostName));
EndpointReference epr = new EndpointReference(address, via);
SoapReceivers.Add(epr, webService);
It looks like the local IP addresses are read once when the
SoapTcpTransport instance is constructed, and never refreshed
afterwards. Hence the "could not be mapped error".
Wouter