C# 将多部分/相关内容发送到SOAP服务.NET核心
我正在尝试设置C# 将多部分/相关内容发送到SOAP服务.NET核心,c#,web-services,soap,asp.net-core,C#,Web Services,Soap,Asp.net Core,我正在尝试设置HttpRequestMessage的头,以便将multipart/relatedHTTP消息发送到SOAP服务 标题需要如下所示: 多部分/相关;边界=MIMEBoundaryurn_uuid7B970E2B89C4446286DDFDBFF7F19581;type=“应用程序/xop+xml”;start=“0.urn:uuid:4628599A1A934415B3EFB15A1888004B@ws.jboss.org>"; start info=“应用程序/soap+xml”
HttpRequestMessage
的头,以便将multipart/related
HTTP消息发送到SOAP服务
标题需要如下所示:
多部分/相关;边界=MIMEBoundaryurn_uuid7B970E2B89C4446286DDFDBFF7F19581;type=“应用程序/xop+xml”;start=“0.urn:uuid:4628599A1A934415B3EFB15A1888004B@ws.jboss.org>"; start info=“应用程序/soap+xml”;action=“urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b”
但是我不知道如何用我的HttpRequestMessage
设置它们。
这是我的密码:
using (var client = new HttpClient(handler))
{
var request = new HttpRequestMessage()
{
RequestUri = new Uri(Host),
Method = HttpMethod.Post
};
var boundary = Guid.NewGuid().ToString();
var bytes = new ByteArrayContent(doc);
bytes.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
var multi = new MultipartContent("related", boundary) {
new StringContent(xml.ToString(), Encoding.UTF8, "text/xml"),
bytes
};
request.Content = multi;
Log.Information(request.Headers.ToString());
Log.Information(request.Content.Headers.ToString());
Log.Information(request.Content.ToString());
var response = client.SendAsync(request).Result;
if (!response.IsSuccessStatusCode)
throw new Exception($"Request resulted in status :{response.StatusCode}");
var stream = response.Content.ReadAsStreamAsync().Result;
using (var sr = new StreamReader(stream))
{
var soapResponse = XDocument.Load(sr);
Log.Information("Soap response : " + soapResponse);
}
}
为什么不使用WCF连接的服务连接到WCF/Soap服务?!它是.NET核心,我无法使用服务的wsdl添加连接的服务。它说wsdl中的URL无效或类似的东西。为什么不使用WCF连接的服务连接到WCF/Soap服务?!它是.NET核心,我无法使用服务的wsdl添加连接的服务。它表示wsdl中的URL无效或类似的内容。