雖然用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);