0

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

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

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

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

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

服务器堆栈跟踪:在 System.IdentityModel.Selectors.CardSpaceShim.InitializeIfNecessary()
在 System.IdentityModel.Selectors.CardSpaceSelector.GetToken(CardSpacePolicyElement[] policyChain, SecurityTokenSerializer tokenSerializer) 在 System.IdentityModel.Selectors.CardSpaceShim.GetCardSpaceImplementationDll()。 ServiceModel.Description.ClientCredentials.GetInfoCardSecurityToken(Boolean requiresInfoCard, CardSpacePolicyElement[] chain, SecurityTokenSerializer tokenSerializer) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at 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(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.EnsureDisplayUI() at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[]出,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)

[1] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 CLIIkarosImport.ImportUploadService 处的 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)。 IImportUploadService.UploadFile(FileUploadMessage request) at CLIIkarosImport.ImportUploadService.ImportUploadServiceClient.CLIIkarosImport.ImportUploadService.IImportUploadService.UploadFile(FileUploadMessage request) in C:\projekte_c#\CLIIkarosImport\CLIIkarosImport\Service References\ImportUploadService\Reference.cs:line 194 at CLIIkarosImport。 ImportUploadService.ImportUploadServiceClient.UploadFile(Int64 FileSize, String OriginalFileName, String UserIpV4, String UserIpV6, String UserName, Stream FileStream, String& FileId, String& Message) 在 C:\projekte_c#\CLIIkarosImport\CLIIkarosImport\Service References\ImportUploadService\Reference.cs: CLIIkarosImport.Webservice.Import.ImportServiceModule 的第 205 行。<>c__DisplayClass0_0.<.ctor>b__2(Object x) in C:\projekte_c#\CLIIkarosImport\ CLIIkarosImport\Webservice\Import\ImportServiceModule.cs:第 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服务器的任何调用,我会得到相同的异常

4

1 回答 1

0

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

于 2021-09-22T08:34:12.857 回答