Will you add a Web service reference in the class library of C #?

Source: Internet
Author: User

This article is not a very advanced article, just a small part of the VS2008 application, but a small part of you will not necessarily, or you try:

I do not have a lot of distributed development applications, this time there is a project to apply Web service, my development environment is vs2008, the reason why I did not choose the current hot WCF, I have the following reasons:

1: The team responsible for developing Web service does not have much to vs2008, nor can they expect a coveted WCF.
2: Project development time is limited, you are not allowed to take the project to do experiments.
3: The project changes little, the Web service is enough to deal with demand.

Since our project is directly upgraded from 1.1 to 3.5, when upgrading, the Web project directly into a class library, so no matter how much changes in the environment, as long as the compatibility of low-level version, all the original files are available, for example, 1.1 to create a Web page, there will be a RESX resource file, However, the page created in 3.5 is Designer.cs, if you upgrade later, as long as the relevant new file type is created, and then added to the class library, so that the same can enjoy the advanced version of the function, said the more ambiguous, do not know whether people understand.

Now all you have to do is to reference the Web service in such a class library, and intuitively think, just add a reference? Is that really the case?

First, how to refer to the Web application project:


First: Right-click on the Web project, one.


Second: Click Add Web Reference, such as two.


Third: Find the available Web service, if it is a direct search within the solution, if it is external, enter a valid address and then query, which can test Web service, three:


Fourth: When you add a reference successfully , the Web references directory appears. Four, and then it's called.



This should be the most basic way to add a Web service reference. At that time I also follow the idea to add. I found that right-click in the class library does not appear in the " Add Web Reference " that I am familiar with, and the figure five effect appears:

At this point I think it might be that the reason for the upgrade becomes " Add Service Reference ", and the next action is the same as above. Click to appear figure six;



Enter the Web service address, test the connection is successful, add success after the appearance of Figure VII:

However, the call was not as successful as imagined, and the result would be that I added the WCF service . I'm embarrassed about the error code here. Knowing that the reference object is wrong is to have the class library add a Web service, but after clicking on the class library, right-click does not have the option to add a Web service . How to make the class library support adding Web service references has become my biggest challenge. At this point I consulted with my colleagues and basically ruled out the problem because the Web service could be accessed normally through the Web site form.

Friends in the garden. Do you add a Web servece reference to the class library in VS08? I Baidu an afternoon, no results, it is best to ask other colleagues, after several twists and turns, there is a colleague who is too capable to add a Web service reference, I can not believe, I put the method to show a bit;

First: Right-click on the target class library and six:
Second: Click on "Add Service Reference" eight:

The key is the "advanced" button in the lower left corner of the diagram . Click Nine:

Third: Notice, also is the bottom left corner, " Add Web Reference " button finally appeared, click Ten: After the operation will not say much.

Here, the purpose of adding a Web service reference to the class library is finally completed. The operation is not complicated, just really do not understand,vs why to add Web references to put so hidden, is it for the promotion of WCF?

Will you add a Web service reference in the class library of C #?

Related Article

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.