我正在使用Xamarin Android中的Sitecore Mobile SDK。我从MCVE for this!下载了示例项目。 我修改了我的代码,根据我的要求更改了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
答案 0 :(得分: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,&#39;安全&#39;章。