我想從.Net中調用Service Now的webservice,我可以使它適用於插入記錄,但我無法獲得任何GET
s的工作。這是我的工作INSERT
代碼:現在調用服務與.Net的Webservice
public void insertTable(string tableName, string schema, string columnInfo, string shortDesrcipt, string longDescript)
{
using (ServiceNow_u_database_table tableReference = new ServiceNow_u_database_table())
{
insertResponse response = new insertResponse();
System.Net.ICredentials cred = new System.Net.NetworkCredential(Properties.Settings.Default.UserName, Properties.Settings.Default.Password);
tableReference.Credentials = cred;
insert tableInsert = this.getTableData(tableName, schema, columnInfo, shortDesrcipt, longDescript);
try
{
response = tableReference.insert(tableInsert);
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}
}
這工作正常。這裏是不爲GET
工作代碼:
using (ServiceNow_u_database_table tableReference = new ServiceNow_u_database_table())
{
ServiceNowExport.com.servicenow.libertydev.u_database_table.getRecords recordGet = new getRecords();
System.Net.ICredentials cred = new System.Net.NetworkCredential(Properties.Settings.Default.UserName, Properties.Settings.Default.Password);
tableReference.Credentials = cred;
recordGet.name = this._tablePrefix + tableName;
getRecordsResponseGetRecordsResult[] response = tableReference.getRecords(recordGet);
if (response != null && response.Count() > 0)
{
return true;
}
}
當我運行的代碼,response
總是null
。我正在按照this頁面上的說明操作。
我知道它正在連接,因爲如果我殺了證書行,我會得到未經授權的錯誤。任何想法我在這裏做錯了嗎?謝謝!
你給出了'GET'似乎是不完整的片段。這裏給出的是返回'true'而不是'response'。這可能是原因嗎? –
不,在回到真實之前,在if中檢查迴應。該響應應該有它在其中找到的表格(我知道表格在那裏,因爲我爲此測試創建了它)。返回true返回它發現表,但由於我沒有得到響應,所以現在沒有被使用。 – VydorScope