Invoking the Java rest Ful interface instance

Source: Internet
Author: User

HttpWebRequest request = WebRequest.Create ("http://192.168.0.99:8080/wzh-webservice/rest/login?username=shuenjia&password=123456") asHttpWebRequest;//Rest/loginRequest. Method ="Post"; Request. KeepAlive=true; Request. Method="getuserinfobynameandpwd"; Request. AllowAutoRedirect=false; Request. ContentType="application/x-www-form-urlencoded"; byte[] Postdatabtyes = Encoding.UTF8.GetBytes ("param={\ "username\": \ "Shuenjia\", \ "password\": \ "123456\"}"); Request. ContentLength=Postdatabtyes.            Length; Stream Requeststream=request.            GetRequestStream (); Requeststream. Write (Postdatabtyes,0, Postdatabtyes.            Length); Requeststream.            Close (); stringresp; Try            {                using(HttpWebResponse response = Request.) GetResponse () asHttpWebResponse) {StreamReader SR=NewStreamReader (response.                    GetResponseStream (), Encoding.UTF8); Resp=Sr.                ReadToEnd (); }            }            Catch            {            }


HttpWebRequest request = WebRequest.Create ("http://") as HttpWebRequest; Request.            Credentials = new NetworkCredential ("123", "123"); Request.            Method = "POST"; Request.            KeepAlive = true; Request.            AllowAutoRedirect = false; Request.            ContentType = "application/x-www-form-urlencoded";            byte[] Postdatabtyes = Encoding.UTF8.GetBytes ("parameter"); Request. ContentLength = Postdatabtyes.            Length; Stream requeststream = Request.            GetRequestStream (); Requeststream. Write (postdatabtyes, 0, Postdatabtyes.            Length); Requeststream.            Close ();            String resp; try {using (httpwebresponse response = Request. GetResponse () as HttpWebResponse) {StreamReader sr = new StreamReader (response.                    GetResponseStream (), Encoding.UTF8); Resp = Sr.                ReadToEnd (); }            }

Invoking the Java rest Ful interface instance

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.