[WSS]Use RPC protocol to access WSS v3 site
The SharePoint Web Services Application Programming Interface (API) offers an extensive interface that helps to communicate remotely with SharePoint 2007. However, this SharePoint Web Services layer is not the only way to communicate remotely with SharePoint 2007. You can also use FrontPage or SharePoint RPC protocols. These protocols can be used to exchange information between a client computer and SharePoint 2007 and are probably the easiest way to make remote function calls.
WSS RPC protocol overview:
The FrontPage and SharePoint RPC protocols are layered on top of the HTTP protocol. FrontPage RPC method calls are sent to SharePoint 2007 via HTTP POST requests and handled by FrontPage Server Extensions. FrontPage and SharePoint RPC calls are directed to dynamic-link libraries (DLLs). The reason why has to do with the fact that a considerable part of WSS v3 is built in unmanaged code and most of the logic related to working with Sites and lists is provided through dynamic-link libraries (DLLs) containing unmanaged code. Amongst other things, these DLLs support SharePoint RPC and FrontPage RPC calls.
Just like webservice, WCF which use endpoints to expose remote service access points, sharepoint RPC service also expose several central endpoints. There are three FrontPage RPC end points:
n Admin.dll. The main responsibility of admin.dll is to administer SharePoint Sites.
n Author.dll. Author.dll has responsibilities like maintaining hyperlinks, generating and maintaining navigation bars and formatting pages.
n Shtml.dll. Shtml.dll adds functionality to SharePoint Sites, like managing interactive discussion groups, hit counters and search forms.
The access url is something like
And sharepoint RPC uses the owssvr.dll endpoint, the url of which is as below:
Owssvr.dll provides much of the logic for working with Sites and lists and is able to interpret Collaborative Application Markup Language (CAML). CAML strings can be passed as arguments to SharePoint RPC method calls and plays an important role when calling SharePoint RPC methods via HTTP POST requests.
If you have interests in all the supported RPC methods and syntax, you can have a look at the reference in WSS V3 SDK:
Remote Procedure Call Protocol
Samples using RPC protocol to access WSS site/data:
In the following part, I’ll use some sample codes to demonstrate accessing sharepoint data via RPC protocol.
1. Use RPC http post to list documents on a site:
First, we use a winform client application with the following main UI to make simple frontpage RPC calls:
“Site Url” will hold the admin.dll endpoint’s full url, “Request Body” will hold the rpc request body and “Response Body” will display the response content. The “Send Request” button contains the following event handler code:
private void btnSend_Click(object sender, EventArgs e)
HttpWebRequest objRequest = (HttpWebRequest)HttpWebRequest.Create(txtSiteUrl.Text);
objRequest.Method = WebRequestMethods.Http.Post;
objRequest.Credentials = CredentialCache.DefaultCredentials;
objRequest.ContentType = “application/x-www-form-urlencoded”;
StreamWriter sw = new StreamWriter(objRequest.GetRequestStream());
HttpWebResponse objResponse = objRequest.GetResponse() as HttpWebResponse;
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
txtResponse.Text = sr.ReadToEnd();
It simply leverage the .NET webrequest component to make the HTTP post call, the response content will be html format content. You can save it into a htm file to view it.
2. Use http get method to access sharepoint RPC service:
In this example, we will use the dialogview method to show all *.docx files within a document library. This comes in handy if you want to share various documents across multiple SharePoint Sites.
The basic syntax of a SharePoint RPC call via a HTTP GET request looks like this:
The dialogview example shows how to call the SharePoint RPC dialogview method. The dialogview method takes the following parameters:
The dialogview parameter determines the type of view that will be returned. Valid values are: FileOpen, FileSave and SaveForm. FileOpen mode shows an Open dialog box, FileSave mode shows a Save dialog box and SaveForm mode shows a Property form.
The location parameter specifies the Site-relative URL of a document library, folder or file. If you omit this parameter all document libraries within the SharePoint Site will be shown.
The FileDialogFilterValue parameter allows you to filter file types. Examples of valid filter values are: *.doc, *.txt and *.htm.
On a server called “MyWSSServer”, in a SharePoint Site called RPCSite, the SharePoint dialogview RPC call that shows all .docx files in the Shared Documents document library looks like this:
You can type the URL that calls the dialogview method directly into your browser which will display the result as below:
3. Use ASP.NET page/html form to issue PRC http request:
Since there is no codebehind needed, we can directly use notepad to create an aspx page in the sharepoint 12 hive TEMPLATE/LAYOUTS folder(or a custom sub folder under it) and paste the following page content:
<%@ Page Language=”C#” AutoEventWireup=”true” Inherits=”System.Web.UI.Page” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
var strFormDigest = ‘<SetVar Name=”__REQUESTDIGEST”>’
var objPostBody = objForm.elements[“PostBody”];
var objRegPattern = /<\/Method>/g;
objPostBody.value = objPostBody.value.replace(
objRegPattern, strFormDigest + “</Method>”);
<SharePoint:FormDigest ID=”FormDigest1″ runat=”server” />
<input type=”hidden” name=”Cmd” value=”DisplayPost”>
<textarea rows=”18″ name=”PostBody” cols=”72″>
<input type=”submit” value=”Submit” />
<input type=”reset” value=”Reset” />
Do remember to replace the “Action” url to your own WSS site’s RPC endpoint address. The “FormDigest” control is necessary since the RPC endpoint will validate the request via the formdigest value. If you’re programmatically issue such RPC request via WebRequest component, you can manually create an instance of the “FormDigest” control and call its “GetDesignTimeHtml” method to get a digest value.
Save the aspx page and then visit it in browser with its url in a certain WSS site, then paste the following CAML in the text area:
<SetList Scope=”Request”>[list GUID]</SetList>
,18 May 2006 05:50:18 -0000</SetVar>
Replace [list GUID] with the SharePoint list GUID (you can obtain it from web page interface for test). Press the Submit button. You may have time to notice that a form digest is added to the <Method> element within the text area.Examine the CAML response returned by owssvr.dll containing the list schema.
Other tips for using RPC protocol to access sharepoint site:
Frankly speaking, the RPC protocol is not used that much since the existing WSS Object Model and webservice interface have been quite enough for most development cases. Just in case you will have to do lots of sharepoint development via RPC protocol, there are some tools which can help a lot for inspecting and troubleshooting the RPC request/response communications.
HTTP monitor tools such as Fiddler make debugging applications issuing FrontPage and SharePoint RPC method calls easier.
1. Open a command prompt and type the following: Fiddler. This starts the Fiddler – HTTP Debugging Proxy screen. Fiddler is an HTTP monitoring tool.
2. Ensure that Fiddler captures HTTP traffic by clicking File. The Capture Traffic F12 option should be checked.
3. In the left tool pane, click on the request to /services/version.asmx located on http://www.fiddlertool.com.
4. In the upper right tool pane, click on Session Inspector > Raw.
5. In the lower left tool pane, click the Raw tab.
Setting Fiddler in this mode makes it easy to monitor HTTP traffic.
Since Sharepoint Designer use PRC protocol underlyingly, you can learn a lot from opening and interacting with a SharePoint Site in Microsoft Office SharePoint Designer and analyze the FrontPage RPC calls with an HTTP monitor tool on the way.