开发者

WCF: How to connect to service by IP:Port

I need to test WCF service, but have only one computer, so my service and client are running on the same machine. Here is the App.config of WCF Service:

<host>
   <baseAddresses>
       <add baseAddress="http://localhost:8000/MyService"/>
   </baseAddres开发者_StackOverflow中文版ses>
</host>
<endpoint address=""
    binding="wsDualHttpBinding"
    contract="MyService.IMyService"/> 

I need to connect to this service from my client by IP, so i tried following:

 MyClient.Endpoint.Address = 
        new System.ServiceModel.EndpointAddress(
             new Uri("http://" + IP + "/" + Port + "/MyService"));

where IP = "127.0.0.1" and Port = "8000". I also tried to use my real IP address instead of 127.0.0.1 but it doesn't work anyway - client cann't connect to service.

  1. Does it possible to connect by IP if I use wsDualHttpBinding, and if yes,

  2. What Endpoint.Address should I specify for it


You need to specify an address something like this:

http://127.0.0.1:8000/MyService

You need to put a : between the IP address and the port number - not a / as you seem to use (at least in your post).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜