Calling ASMX from Visual Studio 2022

Kmcnet 966 Reputation points
2024-01-17T19:28:54.9233333+00:00

Hello everyone and thanks for the help in advance. I'm trying to access an outside vendor's old asmx web service using Visual Studio 2022 but am running into problems. The wsdl is located at: https://cert.wenoexchange.com/wenox/service.asmx?wsdl. Under Add Service Reference, I selected WCF Web Service ad then tried pointing to both the asmx endpoint as well as the wsdl. The references to the Soap services appears in the project under Connected Services, for example, SoapService, but I can't figure out how to reference these services to instantiate them. This is not my strongest suit, so any help would be appreciated.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,108 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,306 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 71,586 Reputation points
    2024-01-17T21:04:27.94+00:00

    when you add a service reference, VS generates a class to implement calling that service. so its generally:

    var myService = new MyService(); 
    var rs = mySvice.CallMethod();
    

    use the VS explorer to see method names, and parameters types. assuming you are using c#, open the reference.cs under the service connection to see the class you instantiate.


  2. QiYou-MSFT 4,326 Reputation points Microsoft Vendor
    2024-01-18T03:22:29.79+00:00

    Hi @Kmcnet

    Use this method to instantiate the client

    ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
    await client.Yourmethod();
    

    ServiceReference1: ServiceReference1 is namespace. In your project is WENOTesting. Service1Client: Service1 is the name of the service. At the same time, there are some changes that need to be made, let me give you an example:

     public string GetData(int value)
     {
         return string.Format("You entered: {0}", value);
     }
    
    
    

    In the service I have a GetData method, but in your project you have to call it like this:

    string str = await client.GetDataAsync(2);
    

    Res1

    Best Regards

    Qi You

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.