none
Pass the name of the binding to use as the sole parameter. RRS feed

  • Question

  • It is  a configuring the client endpoints lab in WCF. The solution consists of two projects:

    Projects are here.(After.zip)

    The DemoService project, which is a simple WCF service library that implements the IGetHeaders interface. This interface consists of a single method(GetHeaders) that retrieves some information about the headers in the message sent to the service. For this exercise, it returns the Action header.

    The TestClient project, which is a console application that enables you to consume the DemoService service. Aproxy to the DemoService has already been created.

    In the constructor for the object, pass the name of the binding to use as the sole parameter.

    My question: The constructor for the proxy object can take the name the binding.

     DemoService.GetHeadersClient proxy = new DemoService.GetHeadersClient("TcpIGetHeaders");

    But in the service side code, there is no a constructor. How can I pass a parameter in this way? How do you know pass the parameter is the endpoint name?
    Wednesday, August 28, 2013 8:20 PM

Answers

All replies

  • Hi,

    I have downloaded your project, and I found you have no configure file in your client side.

    Please try to configure your client like this and give the TcpIGetHeaders as the endpoint name.

    <system.serviceModel>
      <client>
          <endpoint
                  name="TcpIGetHeaders"
                  address="net.tcp://..."
                  binding="netTcpBinding"
                  contract="your contract" name="NetTcpBinding" />
        </client>
      </system.serviceModel>

    Or you can implement the above just in code behind.

    After that the following will work:

     DemoService.GetHeadersClient proxy = new DemoService.GetHeadersClient("TcpIGetHeaders");

    For more information, please try to refer to:
    http://msdn.microsoft.com/en-us/library/ms751515.aspx .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Thursday, August 29, 2013 6:19 AM
    Moderator
  • Thanks but I think that you missed my point. In the service code.

    namespace DemoService
    {
        public class HeaderService : IGetHeaders
        {
            public string GetHeaders()
            {
                return OperationContext.Current.RequestContext.RequestMessage.Headers.Action;
            }
        }
    }

    There is no constructor, why in the proxy we can pass a parameter to the constructor?

    Thursday, August 29, 2013 12:30 PM
  • Got a solution at here.
    • Marked as answer by ardmore Sunday, September 1, 2013 2:49 PM
    Sunday, September 1, 2013 2:49 PM