Search code examples
asp.net-coresoapwsdlvisual-studio-2019

How to Import Data from SAP using wsdl file and also how to consume the proxy class generated from it


Can somebody please explain me how to use the proxy class as I don't understand it, also I have an Interface in the proxy class how should I implement it to access the method described in IBinding

The generated code for the proxy class is as given below:

public interface IBinding {

/// <remarks/>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://sap.com/xi/A1S/Global/QueryProjectIn/FindProjectByElementsRequest", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("ProjectByElementsResponse_sync", Namespace="http://sap.com/xi/SAPGlobal20/Global")]
ProjectByElementsResponseMessage_sync FindProjectByElements([System.Xml.Serialization.XmlElementAttribute(Namespace="http://sap.com/xi/SAPGlobal20/Global")] ProjectByElementsQueryMessage_sync ProjectByElementsQuery);

}

 [HttpGet]
    public static void Main()
    {
        ProjectByElementsQuerySelectionByElements query = new 
        ProjectByElementsQuerySelectionByElements();
        ProjectByElementsQueryMessage_sync sync = new 
        ProjectByElementsQueryMessage_sync
        {
        ProjectSelectionByElements = query

        };

    
}

Solution

  • Steps to create a web reference : Visual Studio -> Add Service Reference -> paste the wsdl document path in your local machine -> click Go

    A service will be visible as per the wsdl and the corresponding methods can be seen by clicking on the service name then in Advanced section a web service button is available, make a web reference by writing the name of the web reference and click on the button a web reference will automatically be added to the project.

    Instantiate the reference file and access the method for connection :

    using webreference;
    var service = new service();
            service.Credentials = new System.Net.NetworkCredential("username", "password");
            service.Url = "https://" + xxx.com";