-
Notifications
You must be signed in to change notification settings - Fork 381
Description
I'm trying to steer namespace prefixes on my responses as I'm re-implementing an existing service.
I have succeeded to get it to work on my regular responses by overriding the namespace manager:
var soapNamespaceManager = new XmlNamespaceManager(new NameTable());
soapNamespaceManager.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
app.UseSoapEndpoint<ISoapEndpoint>(options =>
{
options.SoapSerializer = SoapSerializer.XmlSerializer;
options.XmlNamespacePrefixOverrides = soapNamespaceManager;
});
But I cannot get it to be correct for faults, where the namespace on the faultcode is s:Server
, but should be soap:Server
.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>s:Server</faultcode>
<faultstring>Delivery error</faultstring>
<detail>
<fault xmlns="..." xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<code>22</code>
<reason>Delivery error</reason>
</fault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
If I add new FaultCode("Server", "http://schemas.xmlsoap.org/soap/envelope/"))
to my FaultException I get <a:faultcode xmlns:a="http://schemas.xmlsoap.org/soap/envelope/">a:Server</a:faultcode>
which is also off.
It looks like the underlying issue is that the s:
is hardcoded in
SoapCore/src/SoapCore/FaultBodyWriter.cs
Line 122 in aa5d590
writer.WriteElementString("faultcode", "s:" + faultException.Code.Name); |
Any suggestions on how to oversteer it?
For regular responses it looks like it is the lookup of the prefix that makes it tick:
SoapCore/src/SoapCore/CustomMessage.cs
Line 46 in aa5d590
var prefix = Version.Envelope.NamespacePrefix(NamespaceManager); |
An alternative would be for me to be able to re-add s
as a prefix in AdditionalEnvelopeXmlnsAttributes
. But those attributes are never passed through to the CustomMessage written in DefaultFaultExceptionTransformer
. I tried overriding that implementation, but the initializers for the NamespaceManager and the AdditionalEnvelopeXmlnsAttributes are internal on the CustomMessage
SoapCore/src/SoapCore/CustomMessage.cs
Line 21 in aa5d590
public System.Collections.Generic.Dictionary<string, string> AdditionalEnvelopeXmlnsAttributes { get; internal set; } |