开发者

how to write the class code to consume the webservice?

i am a newbiest in c#, i am doing web service and got stuck , and have a problem. So i have to project A and B. After i create a web service in project A, i want 开发者_StackOverflow社区project B to consume the web service Project A has create. i know that i have to add web reference but what about after that? what code should i put i the class ? and the data i call from database and i want the data consume through web service put in a gridview in project B, how should i write the code??? i am doing in visualstudio 2010

really need urgent help

hope anyone can reply me asap!!thanks


when you adding web reference you should give a name to it by using this name in your code you can access to the service and consuming service functions as well


Watch video #42 here: http://www.asp.net/general/videos


When you add web references, Visual Studio automatically generates strongly-typed proxy classes for you, base on the definition of the web service. In other words, after adding a web reference, you can straight-away use the generated proxy classes to communicate with the web service.

Below is an excerpt from Creating and using Web Services with the .NET framework and Visual Studio.Net that explains in details what a web reference is:

Visual Studio.Net Web References are proxy classes created on the client to connect to the Web Service running on the server. Inside of the IDE Web references automatically generate code and insert hidden files into your project. This is required because .Net is type safe and in order to compile code that uses the Web Service, the client has to know the method signature of each method that is called.

This is nice as it provides full IntelliSense support in the development environment. However it also means that you need to refresh the Web Reference whenever the Web Service interface changes.

The generated proxy class code is stored in the \WebReferences folder beneath the application directory. There is one source file class for each Web Reference you create by the name of the class you publish. Although you can look at the source you shouldn’t change this code as it will be overwritten next time you update the Web Reference.

To use a Web Reference simply add the namespace of the Web Reference. By default it’ll be YourClientNameSpace.ServerClassNameSpace. Make sure you add this namespace to your list of namespaces (using … in C# or imports … in VB).

You are also recommended to read the article as it has an in-depth discussio of web service in .Net.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜