Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call web service(.wsdl) using asp.net

I got .wsdl file from my client. by using this webservice i need validate customer information. So how to achieve this one .if customer is there or not xml :

 <xs:element name="FetchClubMembershipRequest">
        <xs:annotation>
          <xs:documentation>Request to fetch customers' membership information.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="1" maxOccurs="1" name="Customer_ID" type="xs:string" />
            <xs:element minOccurs="1" maxOccurs="1" name="Customer_Code" type="xs:string" />
            <xs:element minOccurs="1" maxOccurs="1" name="Last_Name" type="xs:string" />
            <xs:element minOccurs="1" maxOccurs="1" name="First_Name" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>

this is from wsdl.file

like image 261
Sridhar Avatar asked Nov 21 '25 20:11

Sridhar


2 Answers

Go to Project > Add Web Reference and enter url or local path to your wsdl file and then VS will fetch the WSDL file, and if everything is fine, it will display it on the left, and enable the Add Reference button at the bottom, so we can add it to our Project.

public yourWebService.xyz ws = new yourWebService.xyz();
Private void btnValidate_Click()
{
   // your webservice validation logic..
   // here m considering your webservice as checking wheather a input is number
 if(ws.checkIsNumber(txtNumber.text))
   //something if true
 else
   //something if wrong
}
like image 108
FosterZ Avatar answered Nov 23 '25 11:11

FosterZ


In your ASP.NET project in Visual Studio, go to references, Add Service Reference, and add a reference to the live webservice that you need to call in your application. This will automatically generate all of the stub code you need to call the service.

See: How to Consume a Web Service.

like image 32
Aaronontheweb Avatar answered Nov 23 '25 11:11

Aaronontheweb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!