Will you add Web Service references to the C # class library?

Source: Internet
Author: User

This article is not profoundArticleOnly a small part of the vs2008 application, but a small part of the application may not, or you may try it:

I am not very familiar with distributed development applications. This time, I have a project to apply web service. My development environment is vs2008. The reason why I did not select the popular WCF is as follows:
 

1: The team responsible for developing Web Services does not have many applications for vs2008, and therefore does not expect the coveted WCF.
2: The project development time is limited. You are not allowed to experiment on the project.
3: The project has not changed much, and the Web Service is sufficient to meet the requirements.
 
Because our project is upgraded directly from 1.1 to 3.5, during the upgrade, the web project is directly changed to a class library, so no matter how big the environment changes, as long as it is compatible with low-level versions, all original files are usable. For example, if you create a webpage in 1.1, a resource file in resx is generated, but the webpage created in 3.5 is designer. CS. If you upgrade the file later, you only need to create the new file type and add it to the class library. In this way, you can also enjoy the functions of the advanced version, which is vague, I don't know if you understand it.

What we need to do now is to reference the Web service in such a class library. intuitively, I think that it is enough to add a reference? Is that true?

First, let's talk about how to reference in the Web application project:

1. Right-click a web project and choose 1.

 

2. Click Add web reference, as shown in figure 2.



 

Third: find available Web ServicesIf it is a direct search in this solution, if it is external, enter a valid address and query it. You can test Web Service, 3:

 

Fourth, the reference is successfully added.Then the web references directory. 4 is displayed and called.


This should be the most basic method for adding Web Service references. At that time, I also added it in this way. I found that the"Add web reference", And the following figure shows the effect:

 

 

In this case, I think the reason for the upgrade may be"Add service reference", The subsequent operations are the same as those above. Click figure 6;


Enter the web service address and test the connection. Figure 7 is displayed after the connection is successfully added:

 

However, the call is not as successful as you think, and the result can be thought.WCF Service. Here ErrorCodeI am sorry for the post. After you know that the referenced object is wrong, you need to add the Web service to the class library. However, after you click the class library, right-click"Add Web Service.How to make the class library support adding Web Service referencesIt became my biggest problem. At this time, I consulted my colleagues and basically ruled outProgramProblem, because the website can normally access the Web service.

My friends in the garden will you add web servece references to the class library in vs08?I spent an afternoon in Baidu and had no result. I had to ask another colleague again. After some twists and turns, a talented colleague said that the class library can be used to add Web Service references. I can't believe it, I will paste the method to show it;

1. Right-click the target class library and choose 6:
Second, click "add service reference" 8:

 

The key is"Advanced"Button. Click "9:

Third: note that, in the lower left corner,Add web reference"Button finally appears, click 10: after the operation is not much said.

 

 

At this point, the purpose of adding Web Service references to the class library is finally completed. The operation is not complicated, but it is hard to understand,Why does vs hide Adding web references for the promotion of WCF?

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.