WCF in .net core (TransportWithMessageCredential)

前端 未结 2 1749
没有蜡笔的小新
没有蜡笔的小新 2020-12-17 01:37

When I try to create a connection to a WCF client in dotnet core 2.0, I receive an platform unsupported error:

System.PlatformNotSupportedException: \'The v         


        
相关标签:
2条回答
  • 2020-12-17 02:02

    Actually found a valid workaround, there is a package you can use for this: https://github.com/gravity00/SimpleSOAPClient

    using SimpleSOAPClient;
    using SimpleSOAPClient.Handlers;
    using SimpleSOAPClient.Helpers;
    using SimpleSOAPClient.Models;
    using SimpleSOAPClient.Models.Headers;
    
    ...
    
    _client = SoapClient.Prepare().WithHandler(new DelegatingSoapHandler());
    _client.HttpClient.DefaultRequestHeaders.Clear();
    _client.HttpClient.DefaultRequestHeaders.Add("SOAPAction", "Action...");
    
     var requestEnvelope = SoapEnvelope
         .Prepare()
         .Body(request)
         .WithHeaders(KnownHeader.Oasis.Security.UsernameTokenAndPasswordText(Username, Password));
    
    var responseEnvelope = _client.Send(Url, "CanNotBeEmpty", requestEnvelope);
    

    Got it to work like this, as a charm...

    0 讨论(0)
  • 2020-12-17 02:12

    This has been fixed by the latest packages.

      <ItemGroup>
        <PackageReference Include="System.ServiceModel.Duplex" Version="4.6.0" />
        <PackageReference Include="System.ServiceModel.Http" Version="4.6.0" />
        <PackageReference Include="System.ServiceModel.NetTcp" Version="4.6.0" />
        <PackageReference Include="System.ServiceModel.Security" Version="4.6.0" />
      </ItemGroup>  
    
    0 讨论(0)
提交回复
热议问题