[英]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.