求助:C# 与 webService 通讯问题
wsdl 文件中定义了 安全访问机制如下 :
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken>
<wsp:Policy>
<sp:HttpBasicAuthentication/>
</wsp:Policy>
</sp:HttpsToken>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic128Rsa15/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:All>
那么客户端C# 采用此方法是否可以与 WebServices 进行通讯呢?
HttpWebRequest request = WebRequest.Create(strURL) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/soap+xml; charset=UTF-8";
request.ContentLength = bs.Length;
CredentialCache idCache = new CredentialCache();
idCache.Add(new Uri(strURL), "Basic", new NetworkCredential(username, password));
request.Credentials = idCache;
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(string.Format("{0}:{1}", username, password))));
望懂的朋友指点或者能给个DEMO, 谢谢
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken>
<wsp:Policy>
<sp:HttpBasicAuthentication/>
</wsp:Policy>
</sp:HttpsToken>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic128Rsa15/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:All>
那么客户端C# 采用此方法是否可以与 WebServices 进行通讯呢?
HttpWebRequest request = WebRequest.Create(strURL) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/soap+xml; charset=UTF-8";
request.ContentLength = bs.Length;
CredentialCache idCache = new CredentialCache();
idCache.Add(new Uri(strURL), "Basic", new NetworkCredential(username, password));
request.Credentials = idCache;
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(string.Format("{0}:{1}", username, password))));
望懂的朋友指点或者能给个DEMO, 谢谢
...全文
相关推荐
C#操作webservice(经典入门教程及实例)
C# 操作WebService(经典入门教程及实例)以下是根据给定的文件信息生成的相关知识点:一、WebService 基本概念WebService 是一种可以接收从 Internet 或者 Intranet
C#创建和调用WebService详细教程
使用WebService有许多优点:1. 跨防火墙的通信:WebService可以解决客户端和服务器之间的通信问题,减少开发难度和代码复杂度。2.
C#调用WebService实例与开发教程(推荐)
C#调用WebService实例与开发教程本篇教程将详细讲解C#调用WebService实例的开发过程,帮助开发者快速掌握WebService的调用和开发技术。
C#调用WebService实例开发
C#调用WebService实例开发本文主要介绍了C#调用WebService实例开发,包括基本概念、优点缺点等方面的知识点。一、基本概念WebService也称XML Web Servi
C++、C#写的WebService相互调用
复杂类型问题:解决gsoap生成的WSDL与.NET生成的不兼容问题,可能需要手动调整WSDL或使用特定的gsoap选项。4. 中文字符编码:确保所有通信都在UTF-8或其他支持中文的编码环境下进行。


Web Services
