小编Kev*_*cks的帖子

WordPress WooCommerce ASP.net API WebHookHandler:WebHook请求必须包含格式为HTML表单数据的实体主体

我正在尝试为ASP.NET C#中的WordPress WooCommerce创建一个WebHooks WebHookHandler.

我首先创建了一个ASP.NET C#Azure API App WebApplication Project并添加了相关的引用(Microsoft.AspNet.WebHooks.Common,Microsoft.AspNet.WebHooks.Receivers,Microsoft.AspNet.WebHooks.Receivers.WordPress).添加了WebHookConfig,WordPressWebHookHandler并在GlobalAsax中注册了WebHookConfig.

然后,我将该应用程序发布为Azure App Service.

我的WordPressWebHookHandler仍然是示例的默认值,如下所示:

public class WordPressWebHookHandler : WebHookHandler
{
    public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
    {
        // make sure we're only processing the intended type of hook
        if("WordPress".Equals(receiver, System.StringComparison.CurrentCultureIgnoreCase))
        {
            // todo: replace this placeholder functionality with your own code
            string action = context.Actions.First();
            JObject incoming = context.GetDataOrDefault<JObject>();
        }

        return Task.FromResult(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

在WooCommerce中测试用户创建WebHook时,我可以在日志中看到请求,如下所示.

Webhook请求日志

但不幸的是,它在调试时从未收到,我看到下面的错误.

Webook请求日志错误

我想也许我需要一个自定义WebHook而不是WordPress特定的一个,因为这是一个WooCommerce Webhook.或者可能在路由中处理错误并最终在另一个控制器中.

任何帮助深表感谢.

php c# asp.net wordpress asp.net-webhooks

11
推荐指数
2
解决办法
1593
查看次数

从 .NET 调用 SAP PI 端点时出现“无法识别的消息版本”

我正在使用一个webserviceinvoking类从带有 C# 服务的 .NET 调用 SAP PI。

我正在使用以下方法来做到这一点:

public object InvokeMethod(string serviceName, string methodName, params object[] args)
{
    System.ServiceModel.Channels.Binding defaultBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
    if (this.credentials != null)
    {
        ((BasicHttpBinding)defaultBinding).Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
        ((BasicHttpBinding)defaultBinding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; //.Ntlm;
    }

    object obj = this.webServiceAssembly.CreateInstance(serviceName, false, BindingFlags.CreateInstance, null, new object[] { defaultBinding, new EndpointAddress(this.webServiceUri.ToString()) }, null, null);

    Type type = obj.GetType();

    if (this.credentials != null)
    {
        PropertyInfo piClientCreds = type.GetProperty("ClientCredentials");
        ClientCredentials creds = (ClientCredentials)piClientCreds.GetValue(obj, null);
        creds.UserName.UserName = this.credentials.UserName;
        creds.UserName.Password = this.credentials.Password;
    }

    return …
Run Code Online (Sandbox Code Playgroud)

c# sap web-services sap-xi sap-pi

3
推荐指数
1
解决办法
9443
查看次数

无法从“方法组”转换为“System.EventHandler”

你好 StackOverflow 社区,

我正在使用 c# 开发一个 .NET windows 应用程序,并将一个库项目重建为两个,因为我想在另一个项目中使用一些类。

但是,由于我的更改,我收到错误消息:编译时无法从“方法组”转换为“System.EventHandler”。从一直有效的类/方法。

该应用程序是一个复杂的映射应用程序,它基于自动读取的 CRM 和 Web 服务 WSDL 信息,将 xml/xsd 映射与对象、父子关系、默认值、列表对象和附加功能进行角色化。

以下行给出了错误:“mappingPickListControls = new MappingPickListControls(pMappingPickList, optionMetadataCollection, ValidationRegister, imglblMandatory, tbControlToValidate_validating);”

事件处理程序被赋予控件构建器以确保该方法可以被正确的控件调用以验证正确的信息。

CRMMappingPickListForm:

private void tbControlToValidate_validating(object sender, CancelEventArgs e)
    {
        ValidateControl(this, (Control)sender);
    }

public CRMMappingPickListForm(Ciber.Crm.MappingCRMTo.Data.CustomOptionMetadataCollection optionMetaDataCol, Point location, Size size)
    {
        InitializeComponent();
        this.Location = new Point (location.X + (size.Width / 2) - (Size.Width / 2), location.Y + (size.Height / 2) - (Size.Height / 2));
        optionMetadataCollection = optionMetaDataCol;

        ValidationRegister = new FormValidationRegister();
        ValidationRegister.ControlValidationRegister.Add(new ControlValidation("tbConfigurationName", 1, …
Run Code Online (Sandbox Code Playgroud)

.net c# mapping

2
推荐指数
1
解决办法
4691
查看次数

标签 统计

c# ×3

.net ×1

asp.net ×1

asp.net-webhooks ×1

mapping ×1

php ×1

sap ×1

sap-pi ×1

sap-xi ×1

web-services ×1

wordpress ×1