我正在集成 SOAP 服务,我希望有类似的请求格式,我目前面临的问题是我的请求如下
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:tst="http://schemas.datacontract.org/2004/07/tstSoapCore.wsdl.supply" xmlns:sys="http://schemas.datacontract.org/2004/07/System">
<soapenv:Header/>
<soapenv:Body>
<tem:SupplyService>
<tem:supplyServiceRequest>
<!--Optional:-->
<tst:BN>?</tst:BN>
<!--Optional:-->
<tst:GTIN>?</tst:GTIN>
<!--Optional:-->
<tst:MD>?</tst:MD>
<!--Optional:-->
<tst:SNREQUESTLIST>
<!--Zero or more repetitions:-->
<sys:SN>?</sys:SN>
</tst:SNREQUESTLIST>
<!--Optional:-->
<tst:XD>?</tst:XD>
</tem:supplyServiceRequest>
</tem:SupplyService>
</soapenv:Body>
</soapenv:Envelope>
我很困惑为什么 tem: 和 tst: 和 sys: 存在,这是我的代码
namespace tstSoapCore.wsdl.supply
{
[XmlRoot("SupplyServiceRequest)"]
[DataContract]
//[MessageContract(IsWrapped = true)]//,WrapperName = "SupplyServiceRequest", WrapperNamespace ="sup")]
public class SupplyServiceRequest
{
[DataMember]
public string GTIN { get; set; }
...
}
最后是我的创业
public void ConfigureServices(IServiceCollection services)
{
services.AddSoapCore();
services.TryAddSingleton<SupplyServiceMain>();
}
app.UseEndpoints(endpoints =>
{
endpoints.UseSoapEndpoint<ISupplyService>("/SupplyService.svc",
new BasicHttpBinding(), SoapSerializer.DataContractSerializer);
endpoints.MapGet("/", async context =>
{
context.Response.Redirect("SupplyService.svc");
});
});
}
}
}