We are migrating a Windows Forms App (.NET Framework) to a SOAP web service. You may ask why SOAP instead of REST, the reason is that our client's Point of Sale terminals are only capable of making SOAP requests.
I started by making an ASP.NET Web Application and adding .NET Framework 4.7.2. Then I added an ASMX web service.
[WebService(Namespace = "www.business.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public GetProfileResponse GetClientProfile(Request request)
{
GetProfileResponse getProfileResponse = new GetProfileResponse();
getProfileResponse.responseSuccess = true;
getProfileResponse.responseDetails = "Here are some details";
return getProfileResponse;
}
}
Worked beautifully. Proceeded to add a simple Task from the migrated code.
[WebService(Namespace = "www.business.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public async Task<GetProfileResponse> GetClientProfile(Request request)
{
GetProfileResponse getProfileResponse = new GetProfileResponse();
Tuple<Boolean, Plantilla> taskResult = await new GetClientProfile().get(request.msisdn);
getProfileResponse.responseSuccess = taskResult.Item2.responseSuccess;
getProfileResponse.responseDetails = "Here are some details";
getProfileResponse.subscriberClient = taskResult.Item2.clientName;
return getProfileResponse;
}
}
To my dismay, it does nothing. From what I read, ASMX is incompatible with await and requires an 'IAsyncResult' and 'Callback' wrappings to work, which I failed to understand.
Is there a way to make my code snippet work? If not, is there a more 'modern' alternative for creating a SOAP web service, using .NET, that is compatible with await and tasks?