虽然用config文件可以轻松实现BasicHttpBinding 和 Https,但是如果是一个库的话,最好手工编程实现,这样不用把config文件拷来拷去。
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.MaxReceivedMessageSize = 10 * 1024 * 1024;
EndpointAddress ep = new EndpointAddress(url);
PortalServiceSoap proxy = ChannelFactory<PortalServiceSoap>.CreateChannel(binding, ep);
quoteReturn = proxy.WebMethod(requestObject);