WinForm 调用WebService 隐藏服务器IP地址之真假美猴王~!O(∩_∩)O哈哈~

 

  我们在WinForm项目中添加服务引用后会在App.config文件中添加如下内容:

  

 1 <?xml version="1.0" encoding="utf-8" ?>
 2 <configuration>
 3     <system.serviceModel>
 4         <bindings>
 5             <basicHttpBinding>
 6                 <binding name="TestServicePortBinding" />
 7             </basicHttpBinding>
 8         </bindings>
 9         <client>
10             <endpoint address="http://192.168.168.33:8080/WebTest/TestService"
11                 binding="basicHttpBinding" bindingConfiguration="TestServicePortBinding"
12                 contract="ServiceReference1.TestService" name="TestServicePort" />
13         </client>
14     </system.serviceModel>
15 </configuration>

 

  这样做虽然能够调用WebService却将服务器的IP地址暴露给了客户端。

 

  那么如何解决呢,老夫夜观天象,掐指一算~!搞个真假美猴王吧~!

  

1             WindowsFormsApplication4.ServiceReference1.TestServiceClient testServiceClient = new TestServiceClient();
2             testServiceClient.Endpoint.Address = new EndpointAddress("http://192.168.168.30:8080/WebTest/TestService");
3             testServiceClient.Endpoint.Binding = new BasicHttpBinding();
4             testServiceClient.Endpoint.ListenUri = new Uri("http://192.168.168.30:8080/WebTest/TestService");
5             MessageBox.Show(testServiceClient.jia(1, 2).ToString());

 

转载于:https://www.cnblogs.com/bjxingch/articles/7269076.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值