0

我正在开发 Xamarin Android 中的 Sitecore Mobile SDK。我从https://components.xamarin.com/view/sitecore.mobile.sdk下载了示例项目。我根据我的要求修改了我的代码,更改了 instanceUrl 和凭据并执行了未显示输出的代码。我的应用程序输出显示:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Sitecore.MobileSDK.API.Exceptions.RsaHandshakeException: [Sitecore Mobile SDK] Public key not received properly ---> System.Xml.XmlException: Document Type Declaration (DTD) is prohibited in this XML.  Line 4, position 10.
[MonoDroid]   at Mono.Xml2.XmlTextReader.ReadDoctypeDecl () [0x00000] in <filename unknown>:0 
[MonoDroid]   at Mono.Xml2.XmlTextReader.ReadDeclaration () [0x00000] in <filename unknown>:0 
[MonoDroid]   at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0 
[MonoDroid]   at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
[MonoDroid]   at Sitecore.MobileSDK.PublicKey.PublicKeyXmlParser.Parse (System.IO.Stream xmlStream, CancellationToken cancelToken) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Sitecore.MobileSDK.PublicKey.GetPublicKeyTasks+<>c__DisplayClass11.<ParseResponseDataAsync>b__d () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.TaskActionInvoker+FuncInvoke`1[Sitecore.MobileSDK.PublicKeyX509Certificate].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 
[MonoDroid]   --- End of inner exception stack trace ---
[MonoDroid]   at Sitecore.MobileSDK.ScApiSession+<GetPublicKeyAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[Sitecore.MobileSDK.API.Items.ScItemsResponse].GetResult () [0x00000] in <filename unknown>:0 
[MonoDroid]   at AndroidMobileSdkDemo.MainActivity+<OnCreate>d__2.MoveNext () [0x000d0] in c:\Users\Ashok v\Downloads\Sitecore.Mobile.SDK-1.0\samples\AndroidMobileSdkDemo\AndroidMobileSdkDemo\MainActivity.cs:44 
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
4

1 回答 1

0

未正确收到公钥

检查您的实例设置,应启用 WebAPI:

您应该在 instanceUrl\Website\App_Config\Include\Sitecore.ItemWebApi.config 中启用它

只需更换节点

<site name="website">
<patch:attribute name="itemwebapi.mode">Off</patch:attribute>
<patch:attribute name="itemwebapi.access">ReadOnly</patch:attribute>
<patch:attribute name="itemwebapi.allowanonymousaccess">false</patch:attribute>
</site>

<site name="website">
<patch:attribute name="itemwebapi.mode">StandardSecurity</patch:attribute>
<patch:attribute name="itemwebapi.access">ReadOnly</patch:attribute>
<patch:attribute name="itemwebapi.allowanonymousaccess">true</patch:attribute>
</site>

如果您希望您的匿名用户对该网站具有只读访问权限。您可以在此处找到更多详细信息: https ://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/sitecore_item_web_api_developer_guide_sc65-66-a4.pdf ,“安全”一章。

于 2015-08-07T08:18:22.673 回答