in

SharePoint University

Clean slate. Nothing but SharePoint.
Go, SharePoint!

SharePoint Web Services vs. Object Model APIs

Last post 01-01-2008 10:41 AM by mm_arafa. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-25-2007 2:53 PM

    • Tanuja
    • Top 500 Contributor
    • Joined on 06-21-2007
    • Maryland, USA

    SharePoint Web Services vs. Object Model APIs

    In SharePoint, suppose we want to manipulate the list creation, it can be done either using web services or using direct APIs.

    Can anyone tell which is the prefered option and why?

    Is there any difference in terms of performance using thes approaches?

  • 06-27-2007 7:28 AM In reply to

    Re: SharePoint Web Services vs. Object Model APIs

    The API is much faster.  As with any web service, there is some over-the-wire overhead that'll cost you some performance. 

    I don't think there is a "preferred" option.  It depends on what you need to do.  In general, use the API if the code executes on the server, and use the web services if the code executes off of the server. 

    -----------
    Mike Hodnick
    http://www.kindohm.com
    Lead Consultant
    Inetium
    http://www.inetium.com
    Filed under: ,
  • 07-06-2007 7:02 PM In reply to

    • AaronH
    • Not Ranked
    • Joined on 07-02-2007
    • Southwest Michigan

    Re: SharePoint Web Services vs. Object Model APIs

    I agree that it's entirely in what you need to do.  If you are writing some routine to automate or abstract list management, then the Web Services may be easier to leverage (and your code will be more portable) and performance wouldn't be an issue. 

    However, if the stuff will always live on the server, then there's no problem using the API.

    One thing the Web Services will give you over the API is AJAX-style dynamic client abilities. 

    What are you trying to do?

  • 08-21-2007 6:07 AM In reply to

    Re: SharePoint Web Services vs. Object Model APIs

    Hi,

    Regarding this thread, could someone give me example how to create task in sharepoint list using web service? I know how to use api, but I would like to connect remotely so talk through web service.

    Thanks in advance

  • 10-02-2007 9:28 AM In reply to

    • AaronH
    • Not Ranked
    • Joined on 07-02-2007
    • Southwest Michigan

    Re: SharePoint Web Services vs. Object Model APIs

    This should do the trick:

    //URL of SharePoint lists Web Service 
    var URL = "http://[HOST]/[PATH]/_vti_bin/lists.asmx";
    
    //SOAP Action string 
    var SoapAction = "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems";
    
    var UpdateXML = '<?xml version="1.0" encoding="utf-8"?>';
    UpdateXML += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '; 
    UpdateXML += 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';
    UpdateXML += 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
    UpdateXML += '<soap:Body>';
    UpdateXML += '<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">';
    UpdateXML += '<listName>[LIST_NAME]</listName>';
    UpdateXML += '<updates>';
    UpdateXML += '<Batch OnError="Continue">';
    UpdateXML += '<Method ID="1" Cmd="New">';
    UpdateXML += '<Field Name="Title">[SOME_TEXT]</Field>';
    UpdateXML += '</Method>';
    UpdateXML += '</Batch>';
    UpdateXML += '</updates>';
    UpdateXML += '</UpdateListItems>';
    UpdateXML += '</soap:Body>';
    UpdateXML += '</soap:Envelope>';
    
    var httpResponse = getServiceResults(URL, SoapAction, UpdateXML);
    
    function getServiceResults(url, soap, xml) { 
    	//Send XML packet to web service and return HTTP response text
    	try {
    		if (xml.length > 0) {
    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    			xmlHttp.open("POST", url, false); 
    			xmlHttp.setRequestHeader("SOAPAction", soap); 
    			xmlHttp.setRequestHeader("Content-Type", "text/xml"); 
    			xmlHttp.send(xml); 
    			return xmlHttp.responseText;
    		}
    	}
    	catch(e) {
    		alert(e.message);
    	}
    }
    
    alert(httpResponse);
    
  • 12-09-2007 10:18 PM In reply to

    Re: SharePoint Web Services vs. Object Model APIs

    Hi Aaron , Can you breif me the 'AJAX' capabilities that we can benefit out while using web services ?

    I have worked a bit on AJAX ,but I am not able to relate correctly .

    Any thoughts woud be of great help

     

    Thanks and regards

    K Bhuvaneshwari

     

  • 01-01-2008 10:41 AM In reply to

    Re: SharePoint Web Services vs. Object Model APIs

     

    Thanks alot,very useful post.


    Regards,
    Mostafa Arafa
Page 1 of 1 (7 items)

Need SharePoint Training? Attend a SharePoint Bootcamp!
Forum content (c) original posters. Everything else (c) 2008 SharePoint Experts, Inc.