[英]Postman Soap POST to C# Class
使用 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.