我正在集成一个Asp.NET应用程序和Acumatica,它需要更新运输信息(跟踪#、承运人等)。当它在Acumatica中可用时。是否有一种方法可以让Acumatica在我的Asp.NET应用程序上调用端点?我已经搜索了很多文档(可用的这里),但是我没有遇到任何东西从Acumatica向另一个web服务发送的信息。
理想情况下,此传出调用将在有效载荷中发送托运对象。
发布于 2017-02-20 15:56:21
在我的回答中,我假设您知道如何从C#代码中调用一些外部服务,对于您来说,如何从Acumatica发送通知是一个挑战。我建议您扩展每个Acumatica图中的每个持久化方法,当对象在db中持久化时,您希望从该图中发送通知。IMHO这方面的最佳选择是覆盖方法持久化(顺便说一句,它覆盖持久化方法在T300中有很好的描述)。在扩展类的代码中,您可以执行以下操作:
public void Persist(PersistDelegate baseMethod)
{
baseMethod(); // calling this method will preserve your changes in db
//here should go your code, that will send push/pop/delete etc web request into your asp.net application. Or in other words your web hook.
}发布于 2018-09-12 22:11:48
发布于 2018-09-12 22:18:40
如果您没有Acumatica2017R2,那么您必须创建自己的扩展项目,然后可以从Acumatica代码调用它:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
namespace MyApp
{
public static class Utility
{
private static WebRequest CreateRequest(string url, Dictionary headers)
{
if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
{
WebRequest req = WebRequest.Create(url);
if (headers != null)
{
foreach (var header in headers)
{
if (!WebHeaderCollection.IsRestricted(header.Key))
{
req.Headers.Add(header.Key, header.Value);
}
}
}
return req;
}
else
{
throw(new ArgumentException("Invalid URL provided.", "url"));
}
}
public static string MakeRequest(string url, Dictionary headers = null)
{
WebResponse resp = CreateRequest(url, headers).GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream());
string response = reader.ReadToEnd();
reader.Close();
resp.Close();
return response;
}
public static byte[] MakeRequestInBytes(string url, Dictionary headers = null)
{
byte[] rb = null;
WebResponse resp = CreateRequest(url, headers).GetResponse();
using (BinaryReader br = new BinaryReader(resp.GetResponseStream()))
{
rb = br.ReadBytes((int)resp.ContentLength);
br.Close();
}
resp.Close();
return rb;
}
}
}然后你可以这样称呼它:
try
{
Utility.MakeRequest(theUrl, anyHeadersYouNeed);
}
catch(System.Net.WebException ex)
{
throw(new PXException("There was an error.", ex));
}https://stackoverflow.com/questions/42307151
复制相似问题