static MessageDescription GetMessage (
OperationDescription od, MethodInfo mi,
OperationContractAttribute oca, bool isRequest,
bool isCallback, Type asyncReturnType)
{
ContractDescription cd = od.DeclaringContract;
ParameterInfo [] plist = mi.GetParameters ();
Type messageType = null;
string action = isRequest ? oca.Action : oca.ReplyAction;
MessageContractAttribute mca;
Type retType = asyncReturnType;
if (!isRequest && retType == null)
retType = mi.ReturnType;
// If the argument is only one and has [MessageContract]
// then infer it as a typed messsage
if (isRequest) {
int len = mi.Name.StartsWith ("Begin", StringComparison.Ordinal) ? 3 : 1;
mca = plist.Length != len ? null :
GetMessageContractAttribute (plist [0].ParameterType);
if (mca != null)
messageType = plist [0].ParameterType;
}
else {
mca = GetMessageContractAttribute (retType);
if (mca != null)
messageType = retType;
}
if (action == null)
action = String.Concat (cd.Namespace,
cd.Namespace.Length == 0 ? "urn:" : cd.Namespace.EndsWith ("/") ? "" : "/", cd.Name, "/",
od.Name, isRequest ? String.Empty : "Response");
if (mca != null)
return CreateMessageDescription (messageType, cd.Namespace, action, isRequest, isCallback, mca);
return CreateMessageDescription (oca, plist, od.Name, cd.Namespace, action, isRequest, isCallback, retType, mi.ReturnTypeCustomAttributes);
}