【问题标题】:Postman Soap POST to C# ClassPostman Soap POST 到 C# 类
【发布时间】:2023-01-20 00:14:50
【问题描述】:

使用 SoapCore 将 POST 从 Postman 发送到 VS .NET Core 7 时,命中服务方法的值为 NULL。我认为我对 SOAP 请求的格式设置错误?感谢所有帮助过的人!

我的自定义模型.cs

[DataContract]
public class MyCustomModel
{
    [DataMember]
    public int Id { get; set; }

    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public string Email { get; set; }
}

示例服务.cs

    public class SampleService : ISampleService
{
    public string Test(string s) // This works
    {
        Console.WriteLine("Test Method Executed!");
        return s;
    }

    public void XmlMethod(XElement xml) // customModel NULL here
    {
        Console.WriteLine(xml.ToString());
    }

    public MyCustomModel TestCustomModel([FromBody] MyCustomModel customModel) // customModel NULL here
    {
        return customModel;
    }
}

启动文件

    public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.TryAddSingleton<ISampleService, SampleService>();
        services.AddSoapCore();
        services.AddMvc();
    }

    public void Configure(IApplicationBuilder app)
    {
        app.UseSoapEndpoint<ISampleService>("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
    }
}

WSDL

邮差

【问题讨论】:

    标签: soap


    【解决方案1】:

    解决方案是标签。

    真正帮助我的是我找到了这篇关于如何将 WSDL 导入 Postman 的帖子。

    enter link description here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-18
      • 2015-11-21
      • 2018-02-11
      • 2018-01-21
      • 2020-09-26
      • 1970-01-01
      相关资源
      最近更新 更多