比如 服务端webservice提供了gzip 客户端在调用的时候怎么使用gzip 。
http://www.xxxxxx.com/aaa.asmx 这样的webservice接口 在调用的时候使用了 vs自动生成了 调用类 但是里面没有gzip的设置 。这个是怎么搞的?
大神们江湖救急!!!
需要翻墙才能看,我把代码部分摘录在下面:
...
// This source code was auto-generated by wsdl, Version=2.0.50727.3038.
public partial class MyWebServiceProxy : System.Web.Services.Protocols.SoapHttpClientProtocol {
...
}
...
public class MyWebServiceProxyGzip : MyWebServiceProxy
{
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
WebRequest webRequest = base.GetWebRequest(uri);
HttpWebRequest httpWebRequest = webRequest as HttpWebRequest;
if (httpWebRequest != null)
{
httpWebRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
}
return webRequest;
}
}
...
public void ReadUserInformation(String userName)
{
MyWebServiceProxyGzip myWebServiceProxyGzip = new MyWebServiceProxyGzip()
{
Url = "http://myservice.mydomain.com/WebService.aspx"
};
UserInformation userInformation = myWebServiceProxyGzip.GetUserInformation(userName);
}