none
Cannot make the web service visible to the whole local network RRS feed

  • Question

  • I have a simple web service that writes in a .txt file  the string inserted in the web service.

    This system works perfectly when I access the webservice through localhost, but when I try to access the webservice by another computer on the local network, changing the "localhost" by the IP address of the PC I do not have access to the web service.

    code:

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using System.IO;using System.Text;/// <summary>/// Summary description for WebService/// </summary>[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService{    public WebService()    {       // Uncomment the following line if using designed components         //InitializeComponent();     }    [WebMethod]    public string HelloWorld(string recebida)    {        escreve_para_ficheiro(@"C:\Users\Ricardo\OneDrive - Universidade do Minho\web_service\web_service.txt", recebida);        return recebida;    }    public void escreve_para_ficheiro(string fileLoc, string text)    {        if (File.Exists(fileLoc))        {            using (StreamWriter sw = File.AppendText(fileLoc))            {                sw.WriteLine(text);            }        }    }}

    Tuesday, February 12, 2019 11:03 AM

All replies

  • Sorry about the code format but i cannot edit the last post.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.IO;
    using System.Text;
    
    /// <summary>
    /// Summary description for WebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService
    {
    
        public WebService()
        {
    
           // Uncomment the following line if using designed components 
            //InitializeComponent(); 
        }
    
        [WebMethod]
    
        public string HelloWorld(string recebida)
        {
            escreve_para_ficheiro(@"C:\Users\Ricardo\OneDrive - Universidade do Minho\web_service\web_service.txt", recebida);
    
            return recebida;
    
        }
    
        public void escreve_para_ficheiro(string fileLoc, string text)
        {
            if (File.Exists(fileLoc))
    
            {
                using (StreamWriter sw = File.AppendText(fileLoc))
    
                {
                    sw.WriteLine(text);
                }
    
            }
    
        }
    }

    Tuesday, February 12, 2019 11:07 AM
  • Hi ricjard,

    Welcome to the MSDN forum.

    According to the description, your issue is about the ASP.NET Web service development and since our forum is to discuss the VS IDE, please redirect to this appropriate forum: https://forums.asp.net/28.aspx/1?WCF+ASMX+and+other+Web+Services and start a new thread with your detail error message that failed to access the web services, like error code 404, 500 or others, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, February 13, 2019 2:43 AM