public virtual void DeserializeRequest (Message message, object [] parameters)
{
if (parameters == null)
throw new ArgumentNullException ("parameters");
CheckMessageVersion (message.Version);
IncomingWebRequestContext iwc = null;
if (OperationContext.Current != null) {
OperationContext.Current.Extensions.Add (new WebOperationContext (OperationContext.Current));
iwc = WebOperationContext.Current.IncomingRequest;
}
var wp = message.Properties [WebBodyFormatMessageProperty.Name] as WebBodyFormatMessageProperty;
var fmt = wp != null ? wp.Format : WebContentFormat.Xml;
if (fmt == WebContentFormat.Raw) {
var rmsg = (RawMessage) message;
parameters [0] = rmsg.Stream;
return;
}
Uri to = message.Headers.To;
UriTemplateMatch match = UriTemplate.Match (Endpoint.Address.Uri, to);
if (match == null)
// not sure if it could happen
throw new SystemException (String.Format ("INTERNAL ERROR: UriTemplate does not match with the request: {0} / {1}", UriTemplate, to));
if (iwc != null)
iwc.UriTemplateMatch = match;
MessageDescription md = GetMessageDescription (MessageDirection.Input);
for (int i = 0; i < parameters.Length; i++) {
var p = md.Body.Parts [i];
string name = p.Name.ToUpperInvariant ();
var str = match.BoundVariables [name];
if (str != null)
parameters [i] = Converter.ConvertStringToValue (str, p.Type);
else {
var serializer = GetSerializer (fmt, IsRequestBodyWrapped, p);
parameters [i] = DeserializeObject (serializer, message, md, IsRequestBodyWrapped, fmt);
}
}
}
}