To add a service reference and add a Web reference comparison

Source: Internet
Author: User
Tags visual studio 2010 wsdl

Original: Add a service reference and add a Web reference comparison

    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)]
[System.ComponentModel.ToolboxItem (False)]
To allow the Web service to be called from the script using ASP. NET AJAX, uncomment the downstream.
[System.Web.Script.Services.ScriptService]
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

To add a service reference and add a Web reference comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.