none
connecting external web service get error: 401:unauthorized

    Question

  • I am using an external sharepoint default web service _vti_bin/lists.asmx;

    I have signed the credential(using both defaultCredential and netowrkCredential) and certificatvalidation to the web service before calling the web service.


    However, I still get an unauthorized error. Can we call external web service? if not, what can i use instead? I need to fetch items from an external spsite.

    Tuesday, March 13, 2012 4:03 PM

Answers

  • There are a couple methods that you can use to debug the request to the webservice. The Service Trace Viewer will help you get the most detailed information to debug the request. Take a look here: http://msdn.microsoft.com/en-us/library/aa751795(v=vs.90).aspx

    SharePoint Developer | @zeemanj | Blog

    • Marked as answer by Shimin Huang Friday, March 23, 2012 6:32 AM
    • Unmarked as answer by sparking Tuesday, March 27, 2012 8:22 AM
    • Marked as answer by sparking Friday, March 30, 2012 9:06 AM
    Wednesday, March 21, 2012 7:37 PM
  • Thank you Jeffrey. trace web service is a very good idea and it works now.

    I found this very good example(must said it's a lot better than  the msdn one) about how to create asp webservice on sharepoint server.

    http://msmvps.com/blogs/windsor/archive/2011/11/04/walkthrough-creating-a-custom-asp-net-asmx-web-service-in-sharepoint-2010.aspx 

    i would like to add serveral steps  here for who is not clear how to add services to _vti_bin folder.

    attach webservice with a link likes this format //server/_layouts/myproject/myservice.asmx; Visual studio can automatically discover your latest service methods.

    Deploy your project. 

    Visual Studio will automatically generate/update .disco and .wsdl files. no need to use gacutil.exe or whatever. 

    map your ISAPI folder to your project. copy .asmx file(myproject/web freferences) to   this ISAPI folder;

    deploy project again. 

    now your web serivce is under folder _vti_bin (//server/_vti_bin/myporject/myservice.asmx)

    • Marked as answer by sparking Friday, March 30, 2012 9:06 AM
    Friday, March 30, 2012 9:06 AM

All replies

  • SharePoint web services are available for use over the local network or internet. Does the account have permissions to access the SharePoint site? You can also use Fiddler Web Debugger and the SharePoint ULS log to check for errors. 


    SharePoint Developer | @zeemanj | Blog

    Tuesday, March 13, 2012 8:01 PM
  • indeed. I build a simple console app to test it. it works. somehow, my custom webservice in SharePoint server doesnt work. no idea why.

    btw I use Admin account to test it.

    Thursday, March 15, 2012 9:28 AM
  • Is there an issue with a custom web service or the default lists.asmx web service? You may want to have a look at this article on how to setup a WCF service on a SharePoint 2010 server: http://msdn.microsoft.com/en-us/library/ff521581.aspx

    SharePoint Developer | @zeemanj | Blog

    Thursday, March 15, 2012 7:30 PM
  • thank you Jeffrey. indeed the lists.asmx works. some methods of my web service work as well. however, the method which return a Datatable does not works. I need to find out why.

    ps: i have passed credential as well. 

    Any idea how shall I debug it?

    Monday, March 19, 2012 11:05 PM
  • There are a couple methods that you can use to debug the request to the webservice. The Service Trace Viewer will help you get the most detailed information to debug the request. Take a look here: http://msdn.microsoft.com/en-us/library/aa751795(v=vs.90).aspx

    SharePoint Developer | @zeemanj | Blog

    • Marked as answer by Shimin Huang Friday, March 23, 2012 6:32 AM
    • Unmarked as answer by sparking Tuesday, March 27, 2012 8:22 AM
    • Marked as answer by sparking Friday, March 30, 2012 9:06 AM
    Wednesday, March 21, 2012 7:37 PM
  • Thank you Jeffrey. My custom web service seems no problem. However, it still ask login.

    my custom service is about retrieve lists data from another spsite(Site A), show and update the data in (Site B);

    I still not understand why my service.credential is not working. It keeps pop-up login dialog for (Site A) 

    Tuesday, March 27, 2012 8:22 AM
  • You might be looking at a generic access denied error that makes it difficult to understand what the real problem is. You'll need to futher analyse the request to be able to find a solution. You'll want to create a simple method to determine if communication works. Then you can further inspect if you have transport issues when working with large amount of data. You could also override the service configuration in the web.config to test authentication types and buffer sizes. 

    Have you tried setting up a simple WCF method? Like in the sample page I provided earlier?


    SharePoint Developer | @zeemanj | Blog

    Tuesday, March 27, 2012 6:05 PM
  • Thank you Jeffrey. trace web service is a very good idea and it works now.

    I found this very good example(must said it's a lot better than  the msdn one) about how to create asp webservice on sharepoint server.

    http://msmvps.com/blogs/windsor/archive/2011/11/04/walkthrough-creating-a-custom-asp-net-asmx-web-service-in-sharepoint-2010.aspx 

    i would like to add serveral steps  here for who is not clear how to add services to _vti_bin folder.

    attach webservice with a link likes this format //server/_layouts/myproject/myservice.asmx; Visual studio can automatically discover your latest service methods.

    Deploy your project. 

    Visual Studio will automatically generate/update .disco and .wsdl files. no need to use gacutil.exe or whatever. 

    map your ISAPI folder to your project. copy .asmx file(myproject/web freferences) to   this ISAPI folder;

    deploy project again. 

    now your web serivce is under folder _vti_bin (//server/_vti_bin/myporject/myservice.asmx)

    • Marked as answer by sparking Friday, March 30, 2012 9:06 AM
    Friday, March 30, 2012 9:06 AM