Click here to Skip to main content
14,971,029 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

How can i use a wsdl file in my local system to consume webservice, i have tried by specifying file path in 'Add Web Reference' , but getting the error 'Invalid at the top level of the document.'


1 solution

open Visual Studio, create a web project or console app, and then right-click on the project and pick "Add Service Reference" from the context menu.

Enter the file path and name into the box and import the WSDL - this will generate a simple, very basic WCF client for you to use. You should find a "YourservicenameClient" class in the generated code which should have methods for each of the defined methods on the WSDL contract.

Instantiate the client and call the methods you want to call - that's all there is!

YourServiceClient client = new YourServiceClient();

if you need to specify the remote URL (not using the one created by default), you can easily do this in the constructor of the proxy client:

YourServiceClient client = new YourServiceClient("configName", "remoteURL");

where "configName" is the name of the endpoint to use (you will use all the settings except the URL), and the "remoteURL" is a string representing the URL to connect to (instead of the one contained in the config).
Praveen_P 24-Sep-14 8:57am
i am getting error when i add my local file path in Add reference

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900