0

I am trying to consume a soap web service from an Azure web functions project. I am having difficultly coding the call to the soap service. I have successfully added a WCF web service reference. The reference.cs file has been generated and the SOAP service is asynchronous.

The code is written in C# DOT.NET core 2.0, connecting to a database hosted in an Azure environment.

I believe I should be using threading and making call to an Asynchronous function. When I try to reference code in a separate class file, I get errors relating to using the static keyword.

public class ExpireData
{
    private readonly string _Endpoint;

    public ExpireData(IConfiguration config)
    {
        _Endpoint = config["ServiceURL"];
    }
    [FunctionName("ExpireData")]
    public void Run([TimerTrigger("0 * * * * *")]TimerInfo myTimer, ILogger log)
    {

        BasicHttpBinding binding = new BasicHttpBinding();
        EndpointAddress address = new EndpointAddress(_Endpoint);
        ServiceSoapClient client = new ServiceSoapClient(binding, address);

        var result = client.ExpireDataAsync();    
    }

The value stored in result is: Id = 1018, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
laney
  • 57
  • 9
  • Change your function signature to `public async Task Run(...` then change the last line of your code to `var result = await client.ExpireDataAsync();`. – Thomas Jun 29 '19 at 08:42
  • 1
    Thanks for your answer, it is correct. It is the same as the answer below :) – laney Jul 02 '19 at 09:16

1 Answers1

0

As suggested by Thomas :

Change your function signature to public async Task Run(...)

Then change the last line of your code to var result = await client.ExpireDataAsync();

DixitArora-MSFT
  • 1,768
  • 1
  • 5
  • 8