Esempio n. 1
0
        /// <summary>
        /// Get response schema
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <returns></returns>
        public Message GetResponseXmlSchemaAsMessage(OperationDescription operationDescription)
        {
            bool isXmlSerializerType;
            Type body = OperationDescriptionUtilites.GetResponseBodyType(operationDescription, out isXmlSerializerType);

            if (IsBodySpecial(body))
            {
                return(GetSpecialBodyDocumentationAsMessage(body, "response"));
            }

            try
            {
                return(GetXmlSchemaAsMessage(body, isXmlSerializerType));
            }
            catch (Exception e)
            {
                return(GetTextMessage(String.Format("Could not generate schema for request. Failed with error: {0}", e.Message)));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the response example
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <returns></returns>
        public Message GetResponseExampleAsMessage(OperationDescription operationDescription)
        {
            bool isXmlSerializerType;
            Type body = OperationDescriptionUtilites.GetResponseBodyType(operationDescription, out isXmlSerializerType);

            if (IsBodySpecial(body))
            {
                return(GetSpecialBodyDocumentationAsMessage(body, "response"));
            }

            try
            {
                object instance = Activator.CreateInstance(body);
                return(OperationDescriptionUtilites.GetResponseFormat(operationDescription) == "Json" ?
                       GetJsonExampleAsMessage(instance, body) :
                       GetXmlExampleAsMessage(instance, body, isXmlSerializerType));
            }
            catch (Exception e)
            {
                return(GetTextMessage(String.Format("Could not generate example for response. Failed with error: {0}", e.Message)));
            }
        }