Acumatica通过客户订单获取销售订单字段

问题描述:

我试图根据基于合同的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”在获取请求?

当您通过基于合同的API进行搜索时,需要为搜索条件中使用的所有字段指定[FieldType]搜索类型的实例而不是[FieldType]值的实例(必须使用StringSearch而不是StringValue情况下):

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

只是为了确认,StringSearch也从合同基于文档中使用的样本中的82页上。

+0

这是绝对正确的!在文档中,它显示如果该项不存在,将返回null,但是我得到一个'PX.Api.ContractBased.NoEntitySatisfiesTheConditionException'。我可以配置它返回Null而不是抛出异常吗? –

+0

不幸的是,没有选项可以将API配置为返回Null而不是抛出异常。如果应用程序中不存在项目,它将继续抛出'NoEntitySatisfiesTheConditionException'。 – RuslanDev