首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Acumatica中发出传出请求或web钩子?

如何在Acumatica中发出传出请求或web钩子?
EN

Stack Overflow用户
提问于 2017-02-17 20:50:49
回答 3查看 912关注 0票数 2

我正在集成一个Asp.NET应用程序和Acumatica,它需要更新运输信息(跟踪#、承运人等)。当它在Acumatica中可用时。是否有一种方法可以让Acumatica在我的Asp.NET应用程序上调用端点?我已经搜索了很多文档(可用的这里),但是我没有遇到任何东西从Acumatica向另一个web服务发送信息。

理想情况下,此传出调用将在有效载荷中发送托运对象。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-02-20 15:56:21

在我的回答中,我假设您知道如何从C#代码中调用一些外部服务,对于您来说,如何从Acumatica发送通知是一个挑战。我建议您扩展每个Acumatica图中的每个持久化方法,当对象在db中持久化时,您希望从该图中发送通知。IMHO这方面的最佳选择是覆盖方法持久化(顺便说一句,它覆盖持久化方法在T300中有很好的描述)。在扩展类的代码中,您可以执行以下操作:

代码语言:javascript
复制
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.
  }
票数 1
EN

Stack Overflow用户

发布于 2018-09-12 22:11:48

当您问这个问题时,这是不可用的,但是推送通知似乎正是您要寻找的:

帮助- https://help.acumatica.com/(W(9))/Main?ScreenId=ShowWiki&pageid=d8d2835f-5450-4b83-852e-dbadd76a5af8

演示文稿- https://adn.acumatica.com/content/uploads/2018/05/Push-Notifications.pdf

票数 2
EN

Stack Overflow用户

发布于 2018-09-12 22:18:40

如果您没有Acumatica2017R2,那么您必须创建自己的扩展项目,然后可以从Acumatica代码调用它:

代码语言:javascript
复制
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;
        }
    }
}

然后你可以这样称呼它:

代码语言:javascript
复制
try
{
  Utility.MakeRequest(theUrl, anyHeadersYouNeed);
}
catch(System.Net.WebException ex)
{
  throw(new PXException("There was an error.", ex));
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42307151

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档