tags:

views:

41

answers:

1

I have a simple Atom 1.0 feed that I've generated, similar to the example shown on MSDN.

However, instead of creating a host and testing the feed via console application, as in the example, I'm attempting to create the endpoint via configuration.

My configuration is as follows:

<system.serviceModel>
        <services>
            <service
                name="MyNamespace.MyService"
                behaviorConfiguration="returnFaults">
                <endpoint
                    address=""
                    binding="basicHttpBinding"
                    contract="MyNamespace.IMyGenericService">
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="returnFaults">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

When I run my WCF service, I'm able to access the stock description page and even use this address as a service reference. However, if I attempt to call the method that returns the feed(http://localhost:SomeVSPort/MyService/GetFeed), I get a blank page with no errors. Setting a breakpoint in the method was unsuccessful as the method does not seem to be getting called.

My question is, how should I be exposing this feed for hosting via IIS? Should I be using a different configuration for my endpoint?

For reference, my service declaration follows:

namespace MyNamespace
{
    [ServiceContract]
    public interface IMyGenericService
    {
        [OperationContract]
        [WebGet]
        Atom10FeedFormatter GetFeed();
    }

    public class MyService: IMyGenericService
    {
        public Atom10FeedFormatter GetFeed()
        {
            SyndicationFeed feed = new SyndicationFeed();

        //SimpleEntry is a local class that holds location information in a GeoRSS Simple format.
            IList<SimpleEntry> entries = new List<SimpleEntry>()
            {
                new SimpleEntry() { ID = "1", Point = "45.256 -71.92", Title = "Point 1" },
                new SimpleEntry() { ID = "2", Point = "-71.92 45.256", Title = "Point 2" }
            };

            feed.Items = entries
                .Select(e => new SyndicationItem()
                {
                    Content = new XmlSyndicationContent(
                        "application/xml",
                        new SyndicationElementExtension(e)),
                    Title = new TextSyndicationContent(e.Title),
                    Id = e.ID
                });

            return new Atom10FeedFormatter(feed);
        }
    }
}
A: 

You're mixing up SOAP (via the basicHttpBinding in your config) and REST (using the AtomFeedFormatter, and the [WebGet] attribute on your operation contract).

You need to choose one or the other. Since you want Atom, I assume you really want webHttpBinding in your config:

<system.serviceModel>
    <services>
        <service
            name="MyNamespace.MyService"
            behaviorConfiguration="returnFaults">
            <endpoint
                address=""
                behaviorConfiguration="RESTBehavior"
                binding="webHttpBinding"
                contract="MyNamespace.IMyGenericService">
            </endpoint>
        </service>
    </services>
    <behaviors>
        <endpointBehaviors>
           <behavior name="RESTBehavior">
              <webHttp/>
           </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="returnFaults">
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

Since REST doesn't have things like WSDL and so on, you can get rid of any MEX related stuff, too - just plain REST.

Check out the WCF REST Developer Center on MSDN for a lot of very useful and informative additional resources!

marc_s