Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Calling webservice

Calling webservice

Scheduled Pinned Locked Moved ASP.NET
xmlhelpcsharpwcfsysadmin
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ramkithepower
    wrote on last edited by
    #1

    I am newbie to webservices I am trying to learn about them, but got struck in the first place itself. Please help me out. My service.cs in the web service. -------------------------------- using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://localhost:1458/forumservices/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string welcome(string name) { return "Welcome " + name; } } now on a button click from another web page protected void Button1_Click(object sender, EventArgs e) { try { soapMessage = @" <?xml version=""1.0"" encoding=""utf-8""?> <soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope""> <soap12:Body> <welcome xmlns=""http://localhost:1458/forumservices/""> <name>Rajas</name> </welcome> </soap12:Body> </soap12:Envelope>"; WebClient mClient = new WebClient(); Response.Write(System.Text.Encoding.ASCII.GetString(mClient.UploadData("http://localhost:1458/forumservices/Service.asmx", "POST", System.Text.Encoding.ASCII.GetBytes(soapMessage)))); } catch (System.Net.WebException ex) { if (ex.Response != null) { Stream strm = ex.Response.GetResponseStream(); StreamReader sr = new StreamReader(strm); Response.Write(sr.ReadToEnd()); } else { Response.Write(ex.InnerException.ToString()); } } } The compilation is fine, but i keep getting some errors as below "The remote server returned an error: (500) Internal Server Error." Please help me out

    Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

    P S 2 Replies Last reply
    0
    • R Ramkithepower

      I am newbie to webservices I am trying to learn about them, but got struck in the first place itself. Please help me out. My service.cs in the web service. -------------------------------- using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://localhost:1458/forumservices/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string welcome(string name) { return "Welcome " + name; } } now on a button click from another web page protected void Button1_Click(object sender, EventArgs e) { try { soapMessage = @" <?xml version=""1.0"" encoding=""utf-8""?> <soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope""> <soap12:Body> <welcome xmlns=""http://localhost:1458/forumservices/""> <name>Rajas</name> </welcome> </soap12:Body> </soap12:Envelope>"; WebClient mClient = new WebClient(); Response.Write(System.Text.Encoding.ASCII.GetString(mClient.UploadData("http://localhost:1458/forumservices/Service.asmx", "POST", System.Text.Encoding.ASCII.GetBytes(soapMessage)))); } catch (System.Net.WebException ex) { if (ex.Response != null) { Stream strm = ex.Response.GetResponseStream(); StreamReader sr = new StreamReader(strm); Response.Write(sr.ReadToEnd()); } else { Response.Write(ex.InnerException.ToString()); } } } The compilation is fine, but i keep getting some errors as below "The remote server returned an error: (500) Internal Server Error." Please help me out

      Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

      P Offline
      P Offline
      Pranay Rana
      wrote on last edited by
      #2

      According to me to consume webservice in you application you need to add webreferace of webservice in you application than to call web service you need to create objct of that and than you can call webservice. Check on following link which give you idea about how to consume website. <a href="http://it.toolbox.com/wiki/index.php/Calling\_a\_web\_service\_from\_Asp.net">http://it.toolbox.com/wiki/index.php/Calling\_a\_web\_service\_from\_Asp.net</a>[<a href="http://it.toolbox.com/wiki/index.php/Calling\_a\_web\_service\_from\_Asp.net" target="_blank" title="New Window">^</a>]

      1 Reply Last reply
      0
      • R Ramkithepower

        I am newbie to webservices I am trying to learn about them, but got struck in the first place itself. Please help me out. My service.cs in the web service. -------------------------------- using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://localhost:1458/forumservices/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string welcome(string name) { return "Welcome " + name; } } now on a button click from another web page protected void Button1_Click(object sender, EventArgs e) { try { soapMessage = @" <?xml version=""1.0"" encoding=""utf-8""?> <soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope""> <soap12:Body> <welcome xmlns=""http://localhost:1458/forumservices/""> <name>Rajas</name> </welcome> </soap12:Body> </soap12:Envelope>"; WebClient mClient = new WebClient(); Response.Write(System.Text.Encoding.ASCII.GetString(mClient.UploadData("http://localhost:1458/forumservices/Service.asmx", "POST", System.Text.Encoding.ASCII.GetBytes(soapMessage)))); } catch (System.Net.WebException ex) { if (ex.Response != null) { Stream strm = ex.Response.GetResponseStream(); StreamReader sr = new StreamReader(strm); Response.Write(sr.ReadToEnd()); } else { Response.Write(ex.InnerException.ToString()); } } } The compilation is fine, but i keep getting some errors as below "The remote server returned an error: (500) Internal Server Error." Please help me out

        Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

        S Offline
        S Offline
        sashidhar
        wrote on last edited by
        #3

        Your Coding looks odd to me ..! I think you are not calling the web service method..! try this link..! http://www.codeproject.com/Messages/3359929/Re-web-service.aspx[^] The Calling is Easy..!Its just like any method but little bit difference..!

        LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

        R 1 Reply Last reply
        0
        • S sashidhar

          Your Coding looks odd to me ..! I think you are not calling the web service method..! try this link..! http://www.codeproject.com/Messages/3359929/Re-web-service.aspx[^] The Calling is Easy..!Its just like any method but little bit difference..!

          LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

          R Offline
          R Offline
          Ramkithepower
          wrote on last edited by
          #4

          Sashi, When I call it using web reference it is working fine. But I have to manually call the web service using xml+soap. got any ideas

          Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

          S 1 Reply Last reply
          0
          • R Ramkithepower

            Sashi, When I call it using web reference it is working fine. But I have to manually call the web service using xml+soap. got any ideas

            Jack Sparrow -------------------------------------- Defeat is not the worst of failures. Not to have tried is the true failure.

            S Offline
            S Offline
            sashidhar
            wrote on last edited by
            #5

            No Brother..! :doh:

            LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups