【问题标题】:CardSpaceException: No version of the CardSpace service was found to be installed on the machineCardSpaceException: 没有发现机器上安装了 CardSpace 服务的版本
【发布时间】:2021-11-14 01:38:27
【问题描述】:

首先,我不知道我在做什么。我是一名 Java 开发人员,我必须修复别人编写的 C# 程序。

我们必须更新 Web 服务并将其移动到另一台机器上。更新包括对 https 的更改。 我必须修复的工具用于将文件上传到 Web 服务,并且与服务在同一台机器上运行。 使用 wsdl 文件通过 SOAP(我认为)进行通信。 SSL 证书是自签名的,但存储在受信任的证书存储中。

首先我尝试更改新服务器的路径,但上传工具抱怨更改为 https。不幸的是,我不再有例外了。

然后我重新导入了新的 wsdl,现在我得到了:

System.IdentityModel.Selectors.CardSpaceException:未发现机器上安装了 CardSpace 服务的版本。请安装 CardSpace 并重试操作。

服务器堆栈跟踪:在 System.IdentityModel.Selectors.CardSpaceShim.GetCardSpaceImplementationDll() 在 System.IdentityModel.Selectors.CardSpaceShim.InitializeIfNecessary()
在 System.IdentityModel.Selectors.CardSpaceSelector.GetToken(CardSpacePolicyElement[] policyChain, SecurityTokenSerializer tokenSerializer) 在 System.ServiceModel.Description.ClientCredentials.GetInfoCardSecurityToken(布尔值 requiresInfoCard、CardSpacePolicyElement[] 链、 SecurityTokenSerializer tokenSerializer) 在 System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, 对象服务器, Object[]& outArgs) 在 System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

在 [0] 处重新抛出异常:在 System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult 结果)
在 System.ServiceModel.Channels.ServiceChannel.DisplayInitializationUI() 在 System.ServiceModel.Channels.ServiceChannel.CallDisplayUIOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel 通道,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(时间跨度 超时,CallOnceManager 级联)在 System.ServiceModel.Channels.ServiceChannel.EnsureDisplayUI() 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)

在 [1] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 CLIIkarosImport.ImportUploadService.IImportUploadService.UploadFile(FileUploadMessage 请求)在 CLIIkarosImport.ImportUploadService.ImportUploadServiceClient.CLIIkarosImport.ImportUploadService.IImportUploadService.UploadFile(FileUploadMessage 请求)在 C:\projekte_c#\CLIIkarosImport\CLIIkarosImport\Service References\ImportUploadService\Reference.cs:第 194 行 CLIIkarosImport.ImportUploadService.ImportUploadServiceClient.UploadFile(Int64 文件大小,字符串 OriginalFileName,字符串 UserIpV4,字符串 UserIpV6, String UserName, Stream FileStream, String& FileId, String& Message) 在 C:\projekte_c#\CLIIkarosImport\CLIIkarosImport\Service References\ImportUploadService\Reference.cs:第 205 行 CLIIkarosImport.Webservice.Import.ImportServiceModule.c__DisplayClass0_0.<.ctor>b__2(Object x) 在 C:\projekte_c#\CLIIkarosImport\CLIIkarosImport\Webservice\Import\ImportServiceModule.cs:line 86

         Get["/ImportFromPublicLocation/{path}"] = x =>
         {
                string newPath = x.path;
                newPath = newPath.Replace("-*-", ".");
                newPath = newPath.Replace("-#-", @"\");

                var path = Uri.UnescapeDataString(newPath);    
                Console.WriteLine($"Given path is {path}");

                if (!File.Exists(path))
                {
                    Console.WriteLine("File doesn't exist!");
                    return new Response() {StatusCode = HttpStatusCode.NoContent};
                }

                var response = new CustomResponse();

                using (var client = new ImportUploadServiceClient())
                {
                    var fileName = Path.GetFileName(path);
                    var fStream = new FileStream(path, FileMode.Open);

                    string id, message;
                    ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
                    try
                    {
                        var fResponse = client.UploadFile(fStream.Length, fileName, "", "", "Import", fStream, out id, out message);
                        Console.WriteLine($"Response is {fResponse}");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                    
                    response.JobId = id;
                    response.Message = message;
                }

                return new JsonResponse<CustomResponse>(response, defaultJsonSerializer);
            };

我不知道是改成 https 还是转移到新服务器的问题。不知道前任有没有对旧机器做任何改动让它工作。

如果您需要更多信息,请告诉我。

编辑: 我认为这是应用程序本身的问题。如果网络服务器关闭并且我在wireshark中找不到对api服务器的任何调用,我会得到同样的异常

【问题讨论】:

    标签: c# .net https wsdl cardspace


    【解决方案1】:

    最后,这是使用 STS(AD FS 或 FS-STS)进行用户身份验证的安全问题,我不得不使用服务提供商提供的 DLL 中的类来连接到服务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-03
      • 2016-03-23
      • 2016-12-15
      相关资源
      最近更新 更多