我試圖根據基於合同的API在Acumatica中的客戶訂單字段檢索單個銷售訂單。請參閱我的代碼,該代碼基於Contract Based Documentation(第82頁)中的代碼。Acumatica通過客戶訂單獲取銷售訂單字段
public SalesOrder GetSalesOrder(string orderNumber)
{
var binding = new System.ServiceModel.BasicHttpBinding()
{
AllowCookies = true,
MaxReceivedMessageSize = 655360,
MaxBufferSize = 655360,
SendTimeout = new TimeSpan(0, 2, 0)
};
var soToBeFound = new SalesOrder()
{
OrderType = new StringValue { Value = "SO" },
CustomerOrder = new StringValue { Value = orderNumber }
};
var address = new System.ServiceModel.EndpointAddress(ConfigurationManager.AppSettings["AcumaticaUrl"]);
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
var existingOrder = (SalesOrder)client.Get(soToBeFound);
client.Logout();
return existingOrder;
}
}
當我執行這個代碼,我得到這個異常:
請求信道超時一段時間後, 00等待答覆:01:59.9880722。將傳遞給調用的超時值增加到 請求或增加綁定上的SendTimeout值。分配給此操作的時間 可能是一個較長的 超時的一部分。」
正如你所看到的,我已經加大了超時2分鐘,這似乎是永遠的。是Acumatica API真的只是這種緩慢的還是我做錯事的代碼
編輯:??
當我嘗試用「OrderNbr」字段,而不是「CustomerOrder」字段中得到的,它完美的作品越來越通過「CustomerOrder」這種方式是不允許的?如果不是,我怎樣才能使用「CustomerOrder」在獲取請求?
這是絕對正確的!在文檔中,它顯示如果該項不存在,將返回null,但是我得到一個'PX.Api.ContractBased.NoEntitySatisfiesTheConditionException'。我可以配置它返回Null而不是拋出異常嗎? –
不幸的是,沒有選項可以將API配置爲返回Null而不是拋出異常。如果應用程序中不存在項目,它將繼續拋出'NoEntitySatisfiesTheConditionException'。 – RuslanDev