To add a service reference and Web reference comparison in a windowsform program
To verify the differences in the book about adding service references and Web references for Visual Studio 2010, experiment.
I. Building a Web Services program project
Create a new project, select the ASP. NET empty Web application, add a Web service to it, and then publish to IIS, the path is http://localhost/hello/hello.asmx, and the service outputs the string primarily through the HelloWorld () method. Hello world, which reads as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. Services;
Namespace Hello
{
<summary>
Summary description of Hello
</summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.Basicprofile1_1)]
[Systemcomponentmodel. Toolboxitem (false //to allow this WEB service to be invoked from a script using ASP., uncomment the downstream.
//[System.Web.Script.Services.ScriptService]
Span class= "PLN" > public class hello : System. Web. Services. WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
II. Establishment of test procedures
Form application, select Add Service reference in project, select Advanced, Add Web citation to use, reference can be seen in service The ServiceReferrence1 that appear under the References folder are: Configuration.svcinfo,configuration91.svcinfo,hello.disco,hello.wsdl,reference.cs,r Eference.svcmap A total of six files, or add a service reference directly. To use the tears and methods in:
You can choose whether to add a Web reference or a service reference when you reference the Web project and Web site solution.
1. Add a Web reference, select the namespace as localhost, and the reference information under the App_WebReferences folder. The following files are available under the localhost folder: hello.disco,hello.discomap,hello.wsdl.
2. Add the service reference, the namespace is Local1, The following files are in the Local1 folder: Configuration.svcinfo,configuration91.svcinfo,hello.disco,hello.wsdl,reference.svcmap.
The effect is as follows