.net core 無法引用失敗的情況
1、通過.net framework 工程進行添加
2、copy 代理類 Reference.cs 到.net core 工程下
3、nuget 添加 System.ServiceModel.Http
4、調用代碼
BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress address = new EndpointAddress("http://192.0.4.223:8088/EnterpriseSpace/BPMService.asmx"); BPMServiceSoapClient client = new BPMServiceSoapClient(binding, address); var response = client.GetHashCode();
連https的webservice情況
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
EndpointAddress address = new EndpointAddress("https://2.20.200.2:8180/test/services/ESBWebService");
ESBServiceClient callClient = new ESBServiceClient(binding, address); //跳過檢查驗證 callClient.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication() { CertificateValidationMode = X509CertificateValidationMode.None, RevocationMode = X509RevocationMode.NoCheck };