locked
Host.Description.Endpoints.Find doesn't work with localhost RRS feed

  • Question

  • endpoint = context.Host.Description.Endpoints.Find(context.incomingMessageheaders.To);

    This doesn't work if the client is using LocalHost in url. In this case incomingMessageheader.To contains Localhost, where as the hosted endpoints is having

    my machine name.

    Regards


    singhhome
    Wednesday, November 24, 2010 6:59 PM

Answers

  • Since you run the code inside the service method, it should know the its own name (method name).

    As for not finding the endpoint - you might want to do the search based on the relative url path and not the full path. So strip the prefix http://..domain name../ and run over the endpoints until you find one which ends with the suffix you got after you remvoed the domain name. System.Net.Uri might be helpful.


    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    • Marked as answer by singhhome Monday, November 29, 2010 5:02 PM
    Friday, November 26, 2010 5:34 PM

All replies

  • Singh,

    Can you give us a little more context as to what you are trying to do and what is going wrong?

    Thanks,

    Michael Green
    WCF Documentation Team

    Wednesday, November 24, 2010 8:47 PM
  • I want to get the serviceName + OperationName from the incoming request.

    I was trying the solution provided at http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/4f421939-ca19-4620-a47f-05e3bf5d4a67

    my problem is that if client is using the service URL as http://localhost/site/service.svc, then the IncomingMessageheader.to is coming as http://localhost/site/service.svc.

    so the code instanceContext.Host.Description.Endpoints.Find(endpointUri); fails because the Endpoints on my service side is

    http://mycompurtername/site/service.svc. due to which the Find(enpointUrl) is returning null

    Is there a way that i can get ServiceName and operationName from incoming request?

    Regards


    singhhome
    Friday, November 26, 2010 5:25 PM
  • Since you run the code inside the service method, it should know the its own name (method name).

    As for not finding the endpoint - you might want to do the search based on the relative url path and not the full path. So strip the prefix http://..domain name../ and run over the endpoints until you find one which ends with the suffix you got after you remvoed the domain name. System.Net.Uri might be helpful.


    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    • Marked as answer by singhhome Monday, November 29, 2010 5:02 PM
    Friday, November 26, 2010 5:34 PM