Tracking it down
At first I thought this was a coercion bug where null
was getting coerced to "null"
and a test of "null" == null
was passing. It's not. I was close, but so very, very wrong. Sorry about that!
I've since done lots of fiddling on wonderfl.net and tracing through the code in mx.rpc.xml.*
. At line 1795 of XMLEncoder
(in the 3.5 source), in setValue
, all of the XMLEncoding boils down to
currentChild.appendChild(xmlSpecialCharsFilter(Object(value)));
which is essentially the same as:
currentChild.appendChild("null");
This code, according to my original fiddle, returns an empty XML element. But why?
Cause
According to commenter Justin Mclean on bug report FLEX-33664, the following is the culprit (see last two tests in my fiddle which verify this):
var thisIsNotNull:XML = <root>null</root>;
if(thisIsNotNull == null){
// always branches here, as (thisIsNotNull == null) strangely returns true
// despite the fact that thisIsNotNull is a valid instance of type XML
}
When currentChild.appendChild
is passed the string "null"
, it first converts it to a root XML element with text null
, and then tests that element against the null literal. This is a weak equality test, so either the XML containing null is coerced to the null type, or the null type is coerced to a root xml element containing the string "null", and the test passes where it arguably should fail. One fix might be to always use strict equality tests when checking XML (or anything, really) for "nullness."
Solution
The only reasonable workaround I can think of, short of fixing this bug in every damn version of ActionScript, is to test fields for "null" and
escape them as CDATA values.
CDATA values are the most appropriate way to mutate an entire text value that would otherwise cause encoding/decoding problems. Hex encoding, for instance, is meant for individual characters. CDATA values are preferred when you're escaping the entire text of an element. The biggest reason for this is that it maintains human readability.
A "ContractFilter mismatch at the EndpointDispatcher" means the receiver could not process the message because it did not match any of the contracts the receiver has configured for the endpoint which received the message.
This can be because:
- You have different contracts between client and sender.
- You're using a different binding between client and sender.
- The message security settings are not consistent between client and sender.
Have at look at the EndpointDispatcher
class for more information on the subject.
So:
Make certain that your client and server contracts match.
- If you've generated your client from a WSDL, is the WSDL up-to-date?
- If you've made a recent change to the contract, have you deployed the right version of both client and server?
- If you've hand-crafted your client contract classes, make sure the namespaces, elements names and action names match the ones expected by the server.
Check the bindings are the same between client and server.
- If you're using a .config file to manage your endpoints, make sure the binding elements match.
Check the security settings are the same between client and server.
- If you're using a .config file to manage your endpoints, make sure the security elements match.
Best Answer
I found a workaround by specifying a request header with a SOAPAction key and value of:
http://tempuri.org/I<My Service Name>/<Method Name>
Hope this helps!