我正在尝试使用基于 Contract 的API,根据Acumatica中的客户订单字段检索单个销售订单 . 请参阅下面的代码,该代码基于Contract Based Documentation(第82页)中的代码 .
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之后等待回复时,请求通道超时 . 增加传递给Request的调用的超时值或增加Binding上的SendTimeout值 . 分配给此操作的时间可能是较长超时的一部分 . “
正如你所看到的,我已经将超时时间增加到2分钟,这似乎是永远的 . Acumatica API真的这么慢吗?或者我在代码中做错了什么?
EDIT:
当我尝试通过“OrderNbr”字段而不是“CustomerOrder”字段时,它完美地工作 . 以这种方式不允许通过“CustomerOrder”获取?如果没有,我如何在get请求中使用“CustomerOrder”?
1 回答
当您通过基于 Contract 的API进行搜索时,需要将[FieldType]搜索类型的实例而不是[FieldType]值分配给搜索条件中使用的所有字段(在您的情况下,必须使用
StringSearch
而不是StringValue
):要确认,
StringSearch
也可以在基于 Contract 的文档中的第82页的示例中使用 .