【问题标题】:Acumatica get Sales Order by Customer Order fieldAcumatica 按客户订单字段获取销售订单
【发布时间】:2017-02-15 17:52:56
【问题描述】:

我正在尝试使用基于合同的 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。增加传递给调用的超时值 请求或增加 Binding 上的 SendTimeout 值。时间 分配给该操作的可能是较长时间的一部分 超时。”

如您所见,我已经将超时时间增加到 2 分钟,这似乎是永远的。 Acumatica API 真的就这么慢吗?还是我在代码中做错了什么?

编辑:

当我尝试使用“OrderNbr”字段而不是“CustomerOrder”字段时,它运行良好。是否不允许以这种方式通过“CustomerOrder”获取?如果没有,如何在获取请求中使用“CustomerOrder”?

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    当您通过基于合同的 API 进行搜索时,需要将 [FieldType]Search 类型的实例而不是 [FieldType]Value 分配给搜索条件中使用的所有字段(必须使用 StringSearch 而不是 @987654322 @在你的情况下):

    var soToBeFound = new SalesOrder()
    {
        OrderType = new StringSearch { Value = "SO" },
        CustomerOrder = new StringSearch { Value = orderNumber }
    };
    

    确认一下,StringSearch 也用于基于合同的文档中第 82 页的示例。

    【讨论】:

    • 这绝对正确!在文档中,它显示如果该项目不存在,将返回 null,但是我得到一个 PX.Api.ContractBased.NoEntitySatisfiesTheConditionException。我可以将其配置为返回 Null 而不是抛出异常吗?
    • 不幸的是,没有选项可以将 API 配置为返回 Null 而不是抛出异常。如果应用程序中不存在某个项目,它将继续抛出NoEntitySatisfiesTheConditionException
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-14
    相关资源
    最近更新 更多