Enc*_*ada 6 c# post wsdl web-services http
这就是我目前设法使用特定Microsoft Web服务的方式.请注意,它位于HTTPS服务器上,并且需要.cer
在操作系统的"根证书颁发机构"中安装用户名,密码和文件.
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.TransportWithMessageCredential;
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
binding.Security.Message.NegotiateServiceCredential = true;
binding.Security.Message.AlgorithmSuite
= System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
binding.Security.Message.EstablishSecurityContext = true;
EndpointAddress endpoint = new EndpointAddress("https://address.of.service");
//"GreatClient" was created for me automatically by running
//"svcutil.exe https://address.of.service?wsdl"
GreatClient client = new GreatClient(binding, endpoint);
//Username and password for the authentication. Notice that I have also installed
//the required .cer certificate into the system's "root certificate authorities".
client.ClientCredentials.UserName.UserName = "username";
client.ClientCredentials.UserName.Password = "password";
//Now I can start using the client as I wish.
Run Code Online (Sandbox Code Playgroud)
我的问题是:我如何获得所有必要的信息,以便我可以使用直接POST到https://address.of.service来使用Web服务,以及如何使用C#实际执行POST?我只想使用POST,我可以使用POST直接向https://address.of.service提供原始XML数据,并将结果作为原始XML数据返回.问题是,什么是原始XML数据以及我应该如何使用POST发送它?
(这个问题的目的:我问的原因是我希望使用除C#和.NET之外的其他东西(例如Ruby或Mac OS X上的Cocoa)来使用此服务.我无法知道如何在地球上这样做,因为我没有任何易于使用的"svcutil.exe"在其他平台上为我生成所需的代码.这就是为什么我认为只是能够使用常规POST使用该服务将允许我更容易在其他平台上使用该服务.)
您尝试做的事情现在听起来很痛苦,如果服务器发生任何变化,继续下去也会很痛苦。这真的是重新发明轮子。
如果你还没有考虑过,我会:
(a) 研究是否可以使用服务的元数据并使用目标平台本机的代理生成器。没有多少平台没有至少一些工具,可以帮助您完成部分工作(如果不是全部的话)。也许重新发布一个针对 Ruby 人员的问题,询问存在哪些框架可以使用 WSDL 的 HTTPS 服务?
(b) 如果您的方案允许,我会考虑使用用 C# 编写的代理,该代理充当服务的外观,将其转换为更易于使用的内容(例如,您可能会使用 ASP.NET MVC WebAPI 之类的东西)它很灵活,可以轻松提供符合标准的响应,您可以保持完全控制)。
我怀疑其中的一条可能会比你现在走的路更容易、更有价值。
归档时间: |
|
查看次数: |
1662 次 |
最近记录: |