-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XmlSerializer: Implement MessageContract(IsWrapped=false) for return results #310
XmlSerializer: Implement MessageContract(IsWrapped=false) for return results #310
Conversation
74c6273
to
92cbff6
Compare
@@ -46,6 +46,33 @@ public void Soap12PingWithActionInHeader() | |||
} | |||
} | |||
|
|||
[TestMethod] | |||
public void Soap12PingWithActionInEnvelopeHeader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is unrelated but to avoid the admin overhead; I have included it to increase test coverage.
@@ -20,151 +22,173 @@ public class ServiceBodyWriter : BodyWriter | |||
private readonly object _result; | |||
private readonly Dictionary<string, object> _outResults; | |||
|
|||
public ServiceBodyWriter(SoapSerializer serializer, OperationDescription operation, string resultName, object result, Dictionary<string, object> outResults) : base(isBuffered: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed this parameter and noted it was just lifted out of operation.ReturnName. I have pulled that logic in here and removed the extra parameter.
} | ||
|
||
protected override void OnWriteBodyContents(XmlDictionaryWriter writer) | ||
{ | ||
// do not wrap old-style single element response into additional xml element for xml serializer | ||
var needResponseEnvelope = _serializer != SoapSerializer.XmlSerializer || _result == null || (_outResults != null && _outResults.Count > 0) || !_operation.IsMessageContractResponse; | ||
switch (_serializer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking the cases in-line I have opted to split the xml/data contract logic internally at a higher level.
This has resulted in simpler logic to follow if you are concerned about a single path and allows me to isolate the serialization change (to not unexpected impact DataContractSerializer). The level of conditional nesting is also reduced based on the serialisation path.
Unfortunately it does duplicate some logic.
92cbff6
to
47e1319
Compare
Hi @kotovaleksandr - are you able to publish a new alpha build which includes this? 👍 |
This follows up the PR where I implemented IsWrapped=false for input parameters (#260). This PR implements it for return parameters. It follows the documentation outlined here.
https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/unwrapped-messages