Exemplo n.º 1
0
        // The service interface allows GET, POST, PUT and DELETE HTTP methods using the Atom Publishing Protocol.
        #region interfaces for exposing the resource over Atom Publishing Protocol.

        public AtomPub10ServiceDocumentFormatter GetDocument()
        {
            ServiceDocument serviceDocument = GetServiceDocument();

            SetAtomServiceDocumentContentType();
            return((AtomPub10ServiceDocumentFormatter)serviceDocument.GetFormatter());
        }
Exemplo n.º 2
0
		public void GetFormatter ()
		{
			var v = new ServiceDocument ();
			var f = v.GetFormatter ();
			Assert.IsTrue (f is AtomPub10ServiceDocumentFormatter, "#1");
			Assert.IsTrue (f.Document == v, "#2");
		}
Exemplo n.º 3
0
        public void GetFormatter()
        {
            var v = new ServiceDocument();
            var f = v.GetFormatter();

            Assert.IsTrue(f is AtomPub10ServiceDocumentFormatter, "#1");
            Assert.IsTrue(f.Document == v, "#2");
        }
Exemplo n.º 4
0
 public override void ExecuteResult(ControllerContext context)
 {
     // NOTE: atompub spec says "application/atomserv+xml",
     // but it causes browsers to download instead of browse
     // and the tools seem to work with "application/xml" just fine
     //context.HttpContext.Response.ContentType = "application/atomserv+xml";
     context.HttpContext.Response.ContentType = "application/xml";
     using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output)) {
         doc.GetFormatter().WriteTo(writer);
     }
 }
        public HttpResponseMessage GetServiceDoc(HttpRequestMessage request)
        {
            string baseUrl = request.BaseUrl("servicedoc");

            ServiceDocument doc = new ServiceDocument();
            var postCollection = new ResourceCollectionInfo()
            {
                Title = new TextSyndicationContent("Posts"),
                Link = new Uri(string.Format("{0}/posts", baseUrl))
            };
            postCollection.Accepts.Add("application/atom+xml;type=entry");

            var wspace = new Workspace() { Title = new TextSyndicationContent("The Blog") };
            wspace.Collections.Add(postCollection);

            doc.Workspaces.Add(wspace);

            return new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new ObjectContent(typeof(AtomPub10ServiceDocumentFormatter), doc.GetFormatter())
            };
        }
        public HttpResponseMessage GetServiceDoc(HttpRequestMessage request)
        {
            ServiceDocument doc = new ServiceDocument {
                BaseUri = new Uri(this.serviceURI)
            };
            List <ResourceCollectionInfo> resources = new List <ResourceCollectionInfo>();

            ResourceCollectionInfo blogsCollection = new ResourceCollectionInfo("Blogs", new Uri(String.Format("{0}/blogs", this.serviceURI)));

            blogsCollection.Accepts.Add("application/atom+xml;type=feed");
            resources.Add(blogsCollection);

            Workspace main = new Workspace("RESTBlogsService", resources);

            doc.Workspaces.Add(main);

            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent(typeof(AtomPub10ServiceDocumentFormatter), doc.GetFormatter())
            };

            return(response);
        }
        public HttpResponseMessage GetServiceDoc(HttpRequestMessage request)
        {
            ServiceDocument doc = new ServiceDocument { BaseUri = new Uri(this.serviceURI) };
            List<ResourceCollectionInfo> resources = new List<ResourceCollectionInfo>();

            ResourceCollectionInfo blogsCollection = new ResourceCollectionInfo("Blogs", new Uri(String.Format("{0}/blogs", this.serviceURI)));
            blogsCollection.Accepts.Add("application/atom+xml;type=feed");
            resources.Add(blogsCollection);

            Workspace main = new Workspace("RESTBlogsService", resources);
            doc.Workspaces.Add(main);

            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
                                               {
                                                   Content = new ObjectContent(typeof(AtomPub10ServiceDocumentFormatter), doc.GetFormatter())
                                               };

            return response;
        }
Exemplo n.º 8
0
        public Message CreateAtom10Response(ServiceDocument document)
        {
            if (document == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("document");
            }
            Message message = Message.CreateMessage(MessageVersion.None, (string)null, document.GetFormatter());

            message.Properties.Add(WebBodyFormatMessageProperty.Name, WebBodyFormatMessageProperty.XmlProperty);
            AddContentType(WebOperationContext.DefaultAtomMediaType, this.OutgoingResponse.BindingWriteEncoding);
            return(message);
        }
        public void GetFormatter_Invoke_ReturnsExpected()
        {
            var document = new ServiceDocument();
            AtomPub10ServiceDocumentFormatter formatter = Assert.IsType <AtomPub10ServiceDocumentFormatter>(document.GetFormatter());

            Assert.Same(document, formatter.Document);
            Assert.Equal("http://www.w3.org/2007/app", formatter.Version);
        }