簡體   English   中英

Watson對話框服務錯誤xml文件的無效架構

[英]Watson Dialog service error invalid schema for xml file

我正在使用node.js來使用Watson Dialog系統。 我正在使用一個函數創建一個新對話框,但是在代碼的某個地方,我遇到了一個奇怪的錯誤,該錯誤與讀取的xml文件有關

{ code: 400,
  error: 'Failed to import file. Possibly due to corrupt or invalid file or system error. - java.lang.IllegalStateException: reader must be on a START_ELEMENT event, not a -1 event',
  conversionLog: 'WARN: No valid xsd schema specified in XML header. Assuming version="WatsonDialogDocument_1.1".\n' }

我使用的是披薩對話框xml,可以作為對話框系統測試的示例,因此我認為問題不在於文件無效。 這是我用來創建對話框的代碼。

  var params = {
  name: req.body.username,
  file: fs.createReadStream(__dirname+'/public/dialogs/users/'+req.body.username+'/'+req.body.username+'.xml')
  };

  dialog_service.createDialog(params, function(err, dialog) {
  if (err)
    console.log(err)
  else
    console.log(dialog);
  });

我在與xml對話框文件相同的文件夾中也有WatsonDialogDocument_1.0.xsd文檔。 在對話框的xml文件中,您也可以找到此文件

<dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

嘗試將版本升級到WatsonDialogDocument_1.1.xsd。 您還應該嘗試首先從REST客戶端發布xml。 cURL或Rest Console。 只是為了確保問題出在xml中而不是代碼中。

順便說一句,您不需要XSD文件即可執行POST。

 <dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM