.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);

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM