tags:

views:

101

answers:

1

I have a IIS hosted WCF service that is configured with a WebHttpBinding. It is the same default WCF service VS2008 creates when you create a new one. The only changes I have made is to allow it to be called from javascript.

In the test method GetData(int value), i return a string that displays the remote clients IP address, port, and useragent. Everything works fine, except I am not expecting the port number it is returning. I am expecting port 80, but instead get something like 49353. Below is the method I am calling.

public string GetData(int value)
    {
        OperationContext context = OperationContext.Current;

        MessageProperties messageProperties = context.IncomingMessageProperties;
        RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;



        return string.Format("Hello {0}! \r\naddress: {1}\r\nport: {2}\r\nuseragent: {3}", 
            value, endpointProperty.Address, endpointProperty.Port, WebOperationContext.Current.IncomingRequest.UserAgent);
    }

Like I said, i am invoking this method from javascript. IIS is configured for port 80, so I am not sure why the port is being reported wrong.

+2  A: 

I think you might have this a bit backwards. Port 80 is where you are listening, but once that happens, it passes that off to a new ephemeral port to handle that connection.

Also, the client is also probably using an ephemeral port to open the connection to port 80. So the client's port is likely some "random" port number outside the typical "fixed" port range (0-1024).

Erich Mirabal
Doh! I am willing to bet you are right. Its all the rain we are getting here, its making me tired. Thanks for the refresher.
Mike_G