1

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?

Felipe La Rotta
  • 343
  • 3
  • 13

1 Answers1

1

I found two interesting alternatives

Who should use CoreWCF?

CoreWCF is intended for customers who have been using WCF on .NET Framework and need WCF support in .NET Core to facilitate modernizing the application. While there is nothing stopping you from adopting CoreWCF in greenfield projects, we would recommend you consider more modern alternatives to SOAP such as gRPC. The sweet spot for CoreWCF is to make it easier to modernize server and clients that have a strong dependency on WCF and SOAP.

https://devblogs.microsoft.com/dotnet/corewcf-v1-released/

The other option would be SoapCore

How to use SoapCore in Asp.net Core project for exposing wsdl at project route folder

I will try them both to see if they work. If you have any experience regarding these options your input will be appreciated.

Felipe La Rotta
  • 343
  • 3
  • 13