简体   繁体   中英

Azure Web Functions Consuming SOAP service - how to make async / WinHttpHandler error

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}"

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM