How to: Create External Application XML Markup

Applies to: SharePoint Foundation 2010

This article explains how to use External Application XML to describe your Silverlight application to SharePoint Foundation so that it can manage the application’s access to data and render a Web Part that hosts the application.

Overview

External Application XML is markup that provides information to SharePoint Foundation about a Silverlight application that is hosted in a Web Part. The markup is only required if the Silverlight application is hosted on a different domain and accesses data from the SharePoint Web site. It can also be used, although it is not required, whenever a SharePoint External Application Provider (EAP) is being used. There are three categories of information in the markup:

  • Identifying information about the Silverlight application and the user name it uses to get data from the SharePoint Web site.

  • Information about the Web Part that hosts the external application.

  • Custom information that can be used by a custom EAP to register the application.

There is more than one way to assign the markup to the Web Part:

  • The markup can be assigned to the Web Part in the SharePoint Foundation UI at the time the Web Part is added to a page. If your Silverlight Web Part solution will use that method, you will need to provide the markup as a file with instructions to users on how to insert it, possibly with local modifications, using the UI.

  • You can also specify the markup as an Application XML property within the Web Part markup of a module in a feature definition (elements.xml) or site definition (onet.xml).

  • Finally, you can set the ApplicationXml property programmatically in, for example, a FeatureInstalled(SPFeatureReceiverProperties) or FeatureActivated(SPFeatureReceiverProperties) event.

Examples of External Application XML

The following is an example of External Application XML markup. For detailed information about the elements and attributes, see External Application XML. UTF-16 is used as the encoding in this example, but you can use any encoding. The children of the <customProperties> element can be any XML markup. If you use custom properties, then you must create a custom EAP to read and process the custom properties.

<?xml version='1.0' encoding='utf-16'?>
<applicationParts xmlns='https://schemas.microsoft.com/sharepoint/2009/fluidapp'>
  <applicationPart>
    <metaData>
      <applicationId>00000000-0000-0000-0000-000000000000</applicationId>
      <applicationUrl>https://www.contoso.com/someapplication.xap</applicationUrl>
      <principal>domain\username</principal>
      <sharepointRequestHandlerUrl>/sp.ashx</sharepointRequestHandlerUrl>
    </metaData>
    <data>
      <webPartProperties>
        <property name='Title'>Title</property>
        <property name='Description'>Description</property>
        <property name='WindowlessMode'>TRUE</property>
        <property name='Height'>200px</property>
        <property name='Width'>100px</property>
        <property name='HelpUrl'>https://www.contoso.com/someapplication/help.aspx</property>
        <property name='HelpMode'>Modal</property>
        <property name='Direction'>NotSet</property>
        <property name='MinRuntimeVersion'>3.0</property>
      </webPartProperties>
      <customProperties>
        <property name='CustomPropertyName'>CustomPropertyInfo </property>
      </customProperties>
    </data>
  </applicationPart>
</applicationParts>

The following is an example of External Application XML inside an <AllUsersWebPart> element in either an elements.xml or an onet.xml file.

<AllUsersWebPart WebPartZoneID="Top_Right" WebPartOrder="2">
<![CDATA[
<webParts>
  <webPart xmlns="https://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="Microsoft.SharePoint.WebPartPages.SilverlightWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="ChromeType" type="chrometype">Default</property>
        <property name="Height" type="unit">600px</property>
        <property name="Url" type="string" />
        <property name="HelpMode" type="helpmode">Navigate</property>
        <property name="ApplicationXml" type="string">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;applicationParts xmlns="https://schemas.microsoft.com/sharepoint/2009/fluidapp"&gt;
  &lt;applicationPart&gt;
    &lt;metaData&gt;
      &lt;applicationId&gt;00000000-0000-0000-0000-000000000000&lt;/applicationId&gt;
      &lt;applicationUrl&gt;https://server/ClientBin/SomeApplication.xap&lt;/applicationUrl&gt;
      &lt;principal&gt;domain\ContosoApp&lt;/principal&gt;
      &lt;sharepointRequestHandlerUrl&gt;/ReqForwarder.ashx&lt;/sharepointRequestHandlerUrl&gt;
    &lt;/metaData&gt;
  &lt;/applicationPart&gt;
&lt;/applicationParts&gt;</property>
        <property name="Hidden" type="bool">False</property>
        <property name="Title" type="string" />
      </properties>
    </data>
  </webPart>
</webParts>
]]>
</AllUsersWebPart>