My advise is to ask for the maker of the service to create a new service that talks swagger. I recently had to consume a soap service, ran into all kinds of specials. Decided to skip the half implemented soap in core.net and called it using a simple post request with a soap envelope in it. You can use the wsdl to craft your classes you need to serialize to xml. (use paste xml as classes in VS!)
private async Task<EnvelopeBody> ExecuteRequest(Envelope request)
{
EnvelopeBody body = new EnvelopeBody();
var httpWebRequest = new HttpRequestMessage(HttpMethod.Post, _serviceUrl);
string soapMessage = XmlSerializerGeneric<Envelope>.Serialize(request);
httpWebRequest.Content = new StringContent(soapMessage);
var httpResponseMessage = await _client.SendAsync(httpWebRequest);
if (httpResponseMessage.IsSuccessStatusCode)
{
using var contentStream = await httpResponseMessage.Content.ReadAsStreamAsync();
Envelope soapResult;
var mySerializer = new XmlSerializer(typeof(Envelope));
using (StreamReader streamReader = new StreamReader(contentStream))
{
soapResult = (Envelope) mySerializer.Deserialize(streamReader);
}
body = soapResult.Body;
}
return body;
}
My soap envelope looks like this:
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.xmlsoap.org/soap/envelope/", IsNullable = false)]
public partial class Envelope
{
private object headerField;
private EnvelopeBody bodyField;
/// <remarks/>
public object Header
{
get
{
return this.headerField;
}
set
{
this.headerField = value;
}
}
/// <remarks/>
public EnvelopeBody Body
{
get
{
return this.bodyField;
}
set
{
this.bodyField = value;
}
}
}