dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.7k stars 560 forks source link

Consume SOAP on .net 8 generate 'Forced circuit exception', but it works on .Net 4.8 #5639

Open DaybsonPaisante opened 2 weeks ago

DaybsonPaisante commented 2 weeks ago

Describe the bug I'm consumming the Soap service located at https://servicos.saude.gov.br/cadsus/CadsusService/v5r0?wsdl. I added the Connected Service Reference (WCF Web Service) through Visual Studio 2022 Community. All classes are generated and I setup my workflow just as I did on .NET 4.8.1 (VS 2015 or 2017, don't remember exactly). But I'm getting the error 'Forced circuit exception' when calling the method "Pesquisar" (Search), which should search for a user given an document id.

The project runs fine on .net 4.8. Any reason why the project is not working on .net Core?

Sample Console application project to reproduce the error. https://github.com/DaybsonPaisante/cadsus-demo

CadsusServicePortTypeClient client;

client = new CadsusServicePortTypeClient(CadsusServicePortTypeClient.EndpointConfiguration.CadsusServicePort);

//Public credentials for test environment
var clientCredentials = client.ClientCredentials;
clientCredentials.UserName.UserName = "CADSUS.CNS.PDQ.PUBLICO";
clientCredentials.UserName.Password = "kUXNmiiii#RDdlOELdoe00966";

var result = client.pesquisar(
      new requestPesquisar
      {
          FiltroPesquisa = new FiltroPesquisa
          {
              CPF = new CPFType
              {
                  numeroCPF = "66105234368" // search for some person using his ID
              },
              tipoPesquisa = TipoPesquisaType.IDENTICA
          }
      });

foreach (var item in result)
{
    Console.WriteLine(item.NomeCompleto); //print the full name person's
}

To Reproduce Call stack: System.ServiceModel.FaultException HResult=0x80131500 Message=Forced circuit exception

Source=System.ServiceModel.Primitives StackTrace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(MethodCall methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(MethodInfo targetMethod, Object[] args) at generatedProxy_1.pesquisar(requestPesquisar1 ) at CadsusServiceReference.CadsusServicePortTypeClient.CadsusServiceReference.CadsusServicePortType.pesquisar(requestPesquisar1 request) in C:\Users\m127391\Downloads\cadsus-demo\ConsoleApp\Connected Services\CadsusServiceReference\Reference.cs:line 5186 at CadsusServiceReference.CadsusServicePortTypeClient.pesquisar(requestPesquisar requestPesquisar) in C:\Users\m127391\Downloads\cadsus-demo\ConsoleApp\Connected Services\CadsusServiceReference\Reference.cs:line 5193 at ConsoleApp.Program.Main(String[] args) in C:\Users\xxxxx\Downloads\cadsus-demo\ConsoleApp\Program.cs:line 17

Screenshots image

mconnew commented 2 weeks ago

I used the WSDL url from the ConnectedService.json in your repo as the url you provided above is invalid, it returns a 404 response. Once using the correct WSDL url, I still failed to generate a client as the WSDL is invalid. When running the .NET Framework svcutil it complains about multiple missing components such as some data schema and the bindings being missing. When using the .NET Framework Add Service Reference, there were lots of errors, but it managed to generate the data types but not client or binding. The .NET add WCF connected services tool didn't complain but only created the data types too.

Looking at your sample project, you are adding credentials but they aren't going to be used. This is because there's no client credential type configured, so it will only make anonymous unauthenticated requests. Speaking of credentials, you've publicly posted what looks like real credentials in both your issue post here and in your repro project. You might want to change the password on your account as there are actively bots scraping GitHub for valid credentials.

For you to have generated as much of a client as you have, it looks like the wsdl document is changing over time as you couldn't have generated the code that you did with the current wsdl. If you have this working on .NET Framework, I suggest porting the binding you are using there over as you need to configure the authentication type at least.