因此,我已经将一个ServiceReference添加到了一个C#控制台应用程序中,该应用程序调用了一个从C#公开的Web。
我已经完成了所有的设置,当它不使用SSL (http)时,它就像桃子一样工作。我现在正在尝试使用SSL来设置它,并且我在将它添加到服务引用(甚至Web引用)时遇到了问题。例如,当我尝试将服务添加到Visual中时,服务公开的URL (https)没有返回适当的web方法。
基础连接已关闭:发送时发生意外错误。从传输流接收到意外的EOF或0字节。元数据包含无法解析的引用:“https://srs204.mywebsite.ca:7776/SomeDirectory/MyWebService?WSDL”
我遇到的另一个难题是证书管理和部署。我有大约1000个外部客户端站点需要使用这个小工具,它们需要安装在适当的cert存储中的证书才能连接到Web服务。不确定处理这个问题的最佳方法。他们需要去根店吗?
我花了好几个小时在网上寻找各种各样的选择,但在任何地方都找不到一个很好的答案。
总之,我有几个问题要问:
1)在Visual中设置使用SSL的Web服务有哪些好的链接?
2)如何注册证书?它应该在哪一家店存在?我可以用像CertMgr这样的东西来注册吗?
一定有一本好的书/教程/任何东西,它将向我展示关于设置这样的东西的共同的良好实践。我只是找不到它!
发布于 2010-11-22 20:21:12
感谢这个伟大的建议,快速地看看你的东西,你有很多好的想法正在进行。这是我要补充的一点--我正在计算webMethods和(惊喜!)它与连接到的Oracle服务器(SSL3而不是TLS)有相同的问题。你的方法很有效,这是我的增编。
给定静态类"Factory“,提供以下两个便捷的项目:
/// <summary>
/// Used when dispatching code from the Factory (for example, SSL3 calls)
/// </summary>
/// <param name="flag">Make this guy have values for debugging support</param>
public delegate void CodeDispatcher(ref string flag);
/// <summary>
/// Run code in SSL3 -- this is not thread safe. All connections executed while this
/// context is active are set with this flag. Need to research how to avoid this...
/// </summary>
/// <param name="flag">Debugging context on exception</param>
/// <param name="dispatcher">Dispatching code</param>
public static void DispatchInSsl3(ref string flag, CodeDispatcher dispatcher)
{
var resetServicePoint = false;
var origSecurityProtocol = System.Net.ServicePointManager.SecurityProtocol;
try
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
resetServicePoint = true;
dispatcher(ref flag);
}
finally
{
if (resetServicePoint)
{
try { System.Net.ServicePointManager.SecurityProtocol = origSecurityProtocol; }
catch { }
}
}
}然后消费这些东西(毫无疑问,您已经猜到了,但是无论如何在这里放一个滚筒):
var readings = new ArchG2.Portal.wmArchG201_Svc_fireWmdReading.wmdReading[] {
new ArchG2.Portal.wmArchG201_Svc_fireWmdReading.wmdReading() {
attrID = 1, created = DateTime.Now.AddDays(-1), reading = 17.34, userID = 2
},
new ArchG2.Portal.wmArchG201_Svc_fireWmdReading.wmdReading() {
attrID = 2, created = DateTime.Now.AddDays(-2), reading = 99.76, userID = 3
},
new ArchG2.Portal.wmArchG201_Svc_fireWmdReading.wmdReading() {
attrID = 3, created = DateTime.Now.AddDays(-5), reading = 82.17, userID = 4
}
};
ArchG2.Portal.Utils.wmArchG201.Factory.DispatchInSsl3(ref flag, (ref string flag_inner) =>
{
// creates the binding, endpoint, etc. programatically to avoid mucking with
// SharePoint web.config.
var wsFireWmdReading = ArchG2.Portal.Utils.wmArchG201.Factory.Get_fireWmdReading(ref flag_inner, LH, Context);
wsFireWmdReading.fireWmdReading(readings);
});当我有更多的时间时,我会解决线程问题(或者不解决)。
https://stackoverflow.com/questions/853896
复制相似问题