none
Excel web service access RRS feed

  • Question

  • Hi,

    I have a web service with few methods using basic authentication (username & password). How to access the following web service in Excel 2013 ?

    URL : http://test.com

    Username: user

    Password: pass

    Method : GetEmployeeName(ID)

    Thanks,

    Prav


    Wednesday, May 20, 2015 8:36 PM

Answers

  • Hi,

    >> How to access the following web service in Excel 2013 ?

    I have made a Excel add-in to get the Web Service data in Excel 2013, you could refer to.

    public void test()
            {
                WebReference.WebService ws = new WebReference.WebService();
    
                System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();
                NetworkCredential netCred = new NetworkCredential("username", "password");
                myCredentials.Add(new Uri(ws.Url), "Basic", netCred);
                ws.Credentials = myCredentials;
                string result = ws.HelloWorld();
                Excel.Workbook w1 = (Excel.Workbook)Globals.ThisAddIn.Application.ActiveWorkbook;
                Excel.Worksheet s1 = w1.Sheets.get_Item(1);
                  s1.get_Range("A2").Value=result;     
            }
    

    By the way, this is the forum for discussions about Excel develop (VBA, customization), if you want to get data from WebService using built-in features, you could turn to TechNet forum for Excel.

    TechNet forum for Excel: https://social.technet.microsoft.com/Forums/office/en-US/home?forum=excel

    Hope this could help you

    Best Regards

    Lan



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.HlModerator Tuesday, June 2, 2015 3:11 AM
    Thursday, May 21, 2015 10:30 AM
    Moderator