开发者

Setting WCF Endpoint address at runtime?

If I have the 开发者_JAVA百科following:

WSHttpBinding binding = new WSHttpBinding(); 
EndpointAddress endpoint = new EndpointAddress(new Uri("http://xxx:pppp/MyService")); 

MyServiceClient client = new MyServiceClient(binding, endpoint); 

How can I set the endpoint bindingConfiguration? If it helps my app.config is set to:

<endpoint address="http://xxx:pppp/Design_Time_Addresses/WcfServiceLibrary/ManagementService/"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IManagementService"
          contract="ServiceReference.IManagementService">
        <identity>
              <dns value="localhost" />
        </identity>
</endpoint>

However I'm looking to let the user configure this before running the client.

Thanks


Very simple fix!! Sorry to ask a silly question!

binding = new WSHttpBinding("WSHttpBinding_IManagementService");


To set your binding administratively you need to add a binding section to your app.config file:

<system.serviceModel>

  {...}

  <bindings>
    <wsHttpBinding>
        <binding name="WSHttpBinding_IManagementService" {other parameters ...} />
    </wsHttpBinding>
  </bindings>

  {...}

</system.serviceModel>

And if you do not feel confortable with the manual editing, you can use the WCF Service Configuration Editor which you can find in the Visual Studio menu Tools>WCF Service Configuration Editor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜