C # VS2010 calls WebService

Source: Internet
Author: User

How to invoke a webservice that has been released, mainly in 2 steps (VS2010 Environment C #)

    1. Publish the WebService so that it is in service state.

    2. Create an ASP (Java, and so on) to invoke the WebService method.


  1. To publish the WebService, see

    http://mingsuper.blog.51cto.com/8269088/1439419

  2. Create an ASP.

    1) Create an empty ASP.

    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/A1/wKioL1PHgbrSmIo7AAYOD8NqKHM453.jpg "title=" 2014-07-17_155147.jpg "alt=" wkiol1phgbrsmio7aayod8nqkhm453.jpg "/>2" Set up a test page, not too much to describe here

    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/A1/wKiom1PHgOXQFdJ_AAHhrrYw3dM623.jpg "title=" 2014-07-17_155313.jpg "alt=" wkiom1phgoxqfdj_aahhrryw3dm623.jpg "/>3" add a Web reference to WebService and right-click on the project.

    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/A1/wKiom1PHgYThuWtoAAdlpIH2KJk414.jpg "title=" 2014-07-17_155431.jpg "alt=" wkiom1phgythuwtoaadlpih2kjk414.jpg "/>4" Enter the WebService publish path in the popup dialog, click the Go button. When found, the namespace name for this reference is in the following dialog box. (this name will be used in subsequent operations.)

    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/A2/wKiom1PHgf-yq1PoAAH-X5DvUXI858.jpg "title=" 2014-07-17_155553.jpg "alt=" Wkiom1phgf-yq1poaah-x5dvuxi858.jpg "/>

    5) After the introduction is like this

    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3E/A2/wKiom1PHgoixzDDDAAEPU1R_Wtw902.jpg "title=" 2014-07-17_160032.jpg "alt=" Wkiom1phgoixzdddaaepu1r_wtw902.jpg "/>

    6) loginservice.wsdl is a description file of the published WebService

    650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3E/A5/wKiom1PHhCqyEaUyAAIyDKh1Vx0115.jpg "title=" 2014-07-17_160731.jpg "alt=" Wkiom1phhcqyeauyaaiydkh1vx0115.jpg "/> 7) The corresponding WebService class is found directly through the namespace name during the call of ASP.

    Loginservicesoapclient (the class name I published is Loginservice itself with the soapclient). Loginserviceref.userinfo This variable is very interesting, it is not defined in the ASP. NET project, is defined in the WebService project, but can be used in ASP engineering, and the attribute method exists.

Protected void loginbtn_click (object sender, eventargs e)     {         string loginResult;         LoginServiceRef.LoginServiceSoapClient service = new  Loginserviceref.loginservicesoapclient ();         Loginserviceref.userinfo userinfo = new loginserviceref.userinfo ();         //userinfo userinfo = new userinfo ();         userinfo. Username = username.text;        userinfo. password = password.text;        loginresult =  Service. Checkloginuserinfo (userinfo);        loginresult.text =  loginresult;    }


Call result

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/A5/wKiom1PHhhqDdKfqAAC7Ho2oQG0861.jpg "style=" float: none; "title=" 2014-07-17_161513.jpg "alt=" Wkiom1phhhqddkfqaac7ho2oqg0861.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/A5/wKioL1PHhzOBePxyAAC8hJmMXCw873.jpg "style=" float: none; "title=" 2014-07-17_161527.jpg "alt=" Wkiol1phhzobepxyaac8hjmmxcw873.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/A5/wKiom1PHhhqwMUS4AAC773CCrso463.jpg "style=" float: none; "title=" 2014-07-17_161541.jpg "alt=" Wkiom1phhhqwmus4aac773ccrso463.jpg "/>


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.