カスタムコレクションプロパティ(タブ)を持つカスタムWebパーツを作成しました。編集モードで(ブラウザ経由で)カスタムプロパティを編集して保存すると、Webパーツが適切に動作します。私は、Webサービスを使用して、私のカスタムWebパーツを更新したいので、私はWebパーツをエクスポートして、XMLコンテンツを取り、それは(私は簡単にそれをテストすることができ)であるとして、それを渡されたが、エラーがWebサービスを使用してSharepointカスタムWebパーツを保存すると、整形式のXMLエラーが発生する
The file you imported is not valid.
Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML.
Iを発生しましたすでにオンラインのXML検証ツールを使用してXMLを検証し、これはXMLのバリデータによると、よくformexないXMLの原因1、まだ運であるとして、この文
<?xml version="1.0" encoding="utf-16"?>
を削除して、同じエラーが発生しました。
すべてのアイデア?特にTabsプロパティでXMLの何が間違っているのか分かりませんでした。
コード:
string webPartXml = string.Empty;
string pageUrl = currenturl;
Guid storageKey = new Guid(webpartid);
using (StreamReader sr = new StreamReader(@"C:\tab.txt"))
{
webPartXml = sr.ReadToEnd();
}
webPartXml = webPartXml.Replace("<", "<").Replace(">",">");
try
{
svc.SaveWebPart2(pageUrl, storageKey, webPartXml, WebpartpagesSvc.Storage.Shared, false);
}catch(Exception err)
{
throw;
}
Tab.txt(Tab.webpart)
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Test.TabWebPart, Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c9e6068352095bx6" />
<importErrorMessage>Cannot import this web part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ChromeType" type="chrometype">None</property>
<property name="Height" type="unit" />
<property name="PanelHeight" type="int">0</property>
<property name="ShowRoundedTabs" type="bool">False</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="AllowEdit" type="bool">True</property>
<property name="Tabs" type="Test.Tabs, Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c9e6068352095bx6"><?xml version="1.0" encoding="utf-16"?>
<Tabs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TabInfo>
<Tab>
<Title>HTML-TESTING</Title>
</Tab>
</TabInfo>
</Tabs></property>
<property name="CatalogIconImageUrl" type="string" />
<property name="PanelWidth" type="int">0</property>
<property name="AllowConnect" type="bool">True</property>
<property name="AllowClose" type="bool">True</property>
<property name="HelpMode" type="helpmode">Navigate</property>
<property name="ChildTab" type="System.Collections.Specialized.NameValueCollection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934ebb9" />
<property name="Hidden" type="bool">False</property>
<property name="Title" type="string">Tab </property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowHide" type="bool">True</property>
<property name="Description" type="string">for Tab Sample.</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="TitleUrl" type="string" />
<property name="Width" type="unit" />
<property name="ExportMode" type="exportmode">All</property>
<property name="Direction" type="direction">NotSet</property>
<property name="HelpUrl" type="string" />
<property name="TitleIconImageUrl" type="string" />
</properties>
</data>
</webPart>
</webParts>
エラーメッセージ
base {System.SystemException} = {"Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."}
InnerText = "The file you imported is not valid. Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML."
InnerXml = "<errorstring xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">The file you imported is not valid. Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML.</errorstring>"