Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ParsedMessage.ExtractSoapBodythrowsInvalidOperationException: Duplicate attribute.when an envelope declares a namespace prefix on both<Envelope>and<Body>. The exception is thrown while the message is being read, so the operation is never reached and the caller gets a 500.This is legal XML: a descendant element may redeclare a prefix, and redeclaring it to the same URI is redundant rather than invalid. Some SOAP toolkits emit this shape routinely, so a service can start failing on traffic that has not changed.
Fixes #1196.
Cause
XAttributedoes not overrideEquals, soUnioncompares by reference. A declaration appearing on both elements is two distinct objects, both survive the union, andReplaceAttributesthen adds two attributes with the same name.Change
Take the body's own attributes, then only those envelope attributes whose name the body does not already carry.
This also corrects precedence. When
<Body>rebinds a prefix to a different URI than<Envelope>, the body's binding has to win for the body subtree.Unionkept both attributes, so that case threw as well, and merging the other way round would have resolved names against the wrong namespace.ToListforces both sequences to be evaluated while the body still has its attributes.ReplaceAttributesdoes snapshot its content before removing anything, so this is not strictly required, but it makes the ordering explicit rather than depending on that detail.Tests
Two tests added to
RawRequestSoap12Tests. Both fail ondevelopand pass with this change.Soap12PingWithNamespaceDeclarationsRepeatedOnBodyposts the existing Ping payload with the envelope's three prefixes repeated, unchanged, on<soap12:Body>. This is the reported failure.Soap12PingWithPrefixShadowedOnBodycovers the precedence half:tnsis bound to a decoy URI on the envelope and to the service namespace on the body, and the operation element uses the prefix. The request can only dispatch if the body's binding wins; if the envelope's binding won,tns:Pingwould resolve tohttp://example.org/not-tempuriand the operation would not be found.The full suite passes: 295 tests, 0 failures.