-1

I'm trying to call an external API. I have used a WSDL file to generate the service code, and now I want to call an endpoint. I have a class that I want to use to send an agreement to the external API as shown below. The CreateAgreement function is just to create an agreement-object that the external API can receive.

enter image description here

My program.cs looks like this:

enter image description here

When I start the program it just opens up my web browser that says "Hello world!" and nothing else happens. I feel like I am missing something very basic here, but all the tutorials I find just say "just make a client and call the method", but isn't that what I'm doing in the SendAgreement() function? How do I call the desired endpoint?

AgreementPortTypeClient implementation:

enter image description here

PalBo
  • 2,203
  • 3
  • 22
  • 43

1 Answers1

0

I cannot see your AgreementPortTypeClient implementation but make sure you are calling the underlying communication channel, like you would do for example, using WCF (https://learn.microsoft.com/en-us/dotnet/framework/wcf/how-to-specify-a-client-binding-in-code)

Your examples resembles the interfacing to a WCF service so please make sure you are using the right guides. I found an interesting discussion about WSDL interfacing here: How to use a WSDL

Hope this helps!

Stefan
  • 21
  • 1
  • 4
  • I added the implementation to my question. I have followed the second link you provided exactly, with just two minor exceptions to allow for basic authentication as per this guide: https://medium.com/grensesnittet/integrating-with-soap-web-services-in-net-core-adebfad173fb. I'm not sure what you mean by underlying communication channel. – PalBo Nov 07 '19 at 07:59
  • Thanks for the code example, this makes things more clear. I am not able to figure what can be wrong. However, I would suggest the following approaches to further investigate: 1) debug the code and see that the sending code is actually executed in your case 2) look in the Visual Studio's output window to see if there is any runtime exception in ServiceModel 3) simplify your solution and try to connect to a service that does not require authentication - just for testing purposes. Once you have a working prototype, you can re-add it. – Stefan Nov 07 '19 at 08:49
  • I placed a break point in the first line of Main: `CreateHostBuilder(args).Build().Run();` and indeed it seems that when this line completes nothing more happens, so the call does not even get executed. I also tried commenting out this first line, but then I am met with a webpage saying "HTTP Error 500.30 - ANCM In-Process Start Failure " – PalBo Nov 07 '19 at 08:54
  • You need the first line in order to start the entire hosting environment. It seems there is an exception is thrown in `CreateHostBuilder(args).Build().Run();`. Have you looked in the Output window? – Stefan Nov 07 '19 at 09:01