static bool IsResponseStreamOrVoid(OperationDescription operation, ref int numStreamOperations)
        {
            if (operation.Messages.Count <= 1)
            {
                return(true);
            }
            MessageDescription message = operation.Messages[1];

            if (WebHttpBehavior.IsTypedMessage(message) || WebHttpBehavior.IsUntypedMessage(message))
            {
                return(false);
            }
            if (message.Body.Parts.Count == 0)
            {
                if (message.Body.ReturnValue == null || IsVoidPart(message.Body.ReturnValue.Type))
                {
                    return(true);
                }
                else if (IsStreamPart(message.Body.ReturnValue.Type))
                {
                    ++numStreamOperations;
                    return(true);
                }
            }
            return(false);
        }
        static bool IsRequestStreamOrVoid(OperationDescription operation, ref int numStreamOperations)
        {
            MessageDescription message = operation.Messages[0];

            if (WebHttpBehavior.IsTypedMessage(message) || WebHttpBehavior.IsUntypedMessage(message))
            {
                return(false);
            }
            if (message.Body.Parts.Count == 0)
            {
                return(true);
            }
            else if (message.Body.Parts.Count == 1)
            {
                if (IsStreamPart(message.Body.Parts[0].Type))
                {
                    ++numStreamOperations;
                    return(true);
                }
                else if (IsVoidPart(message.Body.Parts[0].Type))
                {
                    return(true);
                }
            }
            return(false);
        }
 static Type GetResponseBodyType(OperationDescription od)
 {
     if (WebHttpBehavior.IsUntypedMessage(od.Messages[1]))
     {
         return(typeof(Message));
     }
     else if (WebHttpBehavior.IsTypedMessage(od.Messages[1]))
     {
         return(od.Messages[1].MessageType);
     }
     else if (od.Messages[1].Body.Parts.Count > 0)
     {
         // If it is more than 0 the response is wrapped and not supported
         return(null);
     }
     else
     {
         return(od.Messages[1].Body.ReturnValue.Type);
     }
 }
        static Type GetRequestBodyType(OperationDescription od, string uriTemplate)
        {
            if (od.Behaviors.Contains(typeof(WebGetAttribute)))
            {
                return(typeof(void));
            }
            else if (WebHttpBehavior.IsUntypedMessage(od.Messages[0]))
            {
                return(typeof(Message));
            }
            else if (WebHttpBehavior.IsTypedMessage(od.Messages[0]))
            {
                return(od.Messages[0].MessageType);
            }
            else
            {
                UriTemplate template = new UriTemplate(uriTemplate);
                IEnumerable <MessagePartDescription> parts =
                    from part in od.Messages[0].Body.Parts
                    where !template.PathSegmentVariableNames.Contains(part.Name.ToUpperInvariant()) && !template.QueryValueVariableNames.Contains(part.Name.ToUpperInvariant())
                    select part;

                if (parts.Count() == 1)
                {
                    return(parts.First().Type);
                }
                else if (parts.Count() == 0)
                {
                    return(typeof(void));
                }
                else
                {
                    // The request is wrapped and not supported
                    return(null);
                }
            }
        }