WebService Publishing and invocation in C #

Source: Internet
Author: User

WebService Publishing and invocation in C #

http://gstarwd.javaeye.com/blog/551307

WebService Learning Online There are a lot of articles, remember a few months ago when learning by an article can be correctly found in C # and call, in a busy time, now turn back to learn when they do not know how to get. Before that article also disappeared, after the two days of groping finally succeeded. Because in the release of WebService encountered many problems, the problem is very simple, on the internet to find a lot of solutions are very fragmented, when the decision to record down, for the future can be referenced.

Steps: (Learning tools:. net2005)

1. First Open C #, new-> website-> (checked) asp.net Web service-> OK, OK, now to create a new webservice, which will automatically have some code, on its "Hello World" bar, a simple test on the line.

2.F5 test, will open a Web page, the display is OK. Then dot generate-> Publishing site-> set a good path-> OK, OK, now in the path you set will have a Asmx,dll file.

3. Open IIS (I am in the Computer Management->internet information Service-> Web site-> The default Web site-> new-> virtual site-> take the site name Wservice, and put your site to publish the path set in ... Then the next step, the site set up OK) then browse the WebService of the newly built website and browse the Service.asmx. will open on the Web page. Note: There will be problems here, I will be open when the error occurs:

'--------------------------------
Configuration error
Description: An error occurred while processing the configuration file required to provide services to the request. Please check the specific error details below and modify the configuration file appropriately.

Parser Error Message: Error loading configuration file: Failed to start monitoring for c:/documents and settings/administrator/my documents/visual Studio 2005/projects/due to access denied Misweb_tube (2). Root/misweb_tube (2)/misweb_tube/website/sysfunction/web.config "change.

SOURCE Error:


[No related source lines]


Source file: C:/Documents and settings/administrator/my documents/visual Studio 2005/projects/misweb_tube (2). root/misweb_ Tube (2)/misweb_tube/website/sysfunction/web.config line: 0
'---------------------------------

After checking the folder without Web.config files, copy a web.config, No. Back to Computer Management, click Computer Management->internet Information Services-> Web site-> Default Web site->wservice ( I have just built the site name)-> has the Task-> Permissions Wizard-> next step, anyway this operation is the permission to open your site, OK, the operation is successful. Then browse the Service.asmx,ok and the Web page turns on normally.

4. Now return to C #, a new WinForm, this operation will not be said. Add a Web reference to your project, and then click on "Web services on your local computer, automatically find the service you just created, click and fetch it." Take a Web reference name and click Add Reference.

OK, the whole webservice will add the reference OK.

5. Above we publish, the reference OK, now we come to call our this webservice, first you have to reference the using class name.  Web reference name; OK reference succeeded, we call, the first place in your call must be this service to instantiate new, otherwise, like me, half a day does not come out of its public methods, white waste a lot of time, depressed, I do this stupid ... I hope you do not like me: (

Now our WebService is published and invoked successfully. OK, okay.

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.