.net core 调用webservice

1.点击core项目添加链接的服务

2.键入对应的webservice地址,下载对应的代理服务

4.由于.net core  代理类只支持异步方法  原有webservice同步方法不会显示 可以使用wait或Result改成同步方式。

1  protected override availableFlightWithPriceAndCommisionReply ExecuteCore(availableFlightWithPriceAndCommisionRequest request) {
2 
3             var service = new GetAvailableFlightWithPriceAndCommisionService_1_0Client();
4 
5             return service.getAvailableFlightWithPriceAndCommisionAsync(request).Result.@return;
6 
7         }

5.如果异步方法返回实体和同步方法返回实体不一样 可以使用AutoMapper映射相应的实体

 AutoMapper.Mapper.Initialize(c=>c.CreateMap<a,b>());
 AutoMapper.Mapper.Map<b>(result);

  

猜你喜欢

转载自www.cnblogs.com/wsprince/p/10566240.html