Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DaybsonPaisante opened this issue Aug 30, 2024 · 1 comment
Labels

Comments

@DaybsonPaisante
Copy link

DaybsonPaisante commented Aug 30, 2024

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
Copy link
Member

mconnew commented Aug 30, 2024

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.

@HongGit HongGit added the triaged label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants