Michaele

Michaele

  • NA
  • 2
  • 0

WCF App to Write out RSS

May 16 2011 11:06 AM

hey,

Platform is .NET 4.0 Framework, starting with template: Syndication Service Library.  will be running in production on MS Server 2008

I need to create a service (that can be called from a remote server) which will add/update items for an RSS feed.

The code seems to be almost working, it will generate the proper xml items for the RSS.  But i still have 2 broad issues:

1) i can't get the code to run on the web server (it only runs on my local machine)

2) when the application runs (on my local machine), it doesn't actually write the xml file, it only brings it up in IE with a prompt for "save/download"

 

I guess it might be best to start with problem (1).  How can i get the application to run on the production server.

Here is the class with code.  Any help is greatly appreciated!  this is totally new for me, so i'm probably  missing something obvious.

namespace AlertSyndication
{
   
   
public class Alerts : IAlerts
   
{
       
public SyndicationFeedFormatter CreateFeed()
       
{
           
// DECLARE VARIABLES

             
string alertURL;                   // holds final URL value of given alert
           
Uri alertUri;                       // holds final URL value of given alert as datatype URI
           
SyndicationItem item;               // a SyndicationItem object (an object to hold title, description and URL for each RSS <item>)

           
// Instantiate new alert proxy object
             
ActiveAlerts.ActiveAlertsSoapClient  currentAlerts = new ActiveAlertsSoapClient();
           
           
           
// Create a new Syndication Feed.
           
SyndicationFeed alerts = new SyndicationFeed("My Alerts", "Information from the alert system", null);
           
List<SyndicationItem> items = new List<SyndicationItem>();

           
// Begin adding items
           
try
           
{

               
// grab the alerts and store them in a list
               
List<Alert> lAlerts = currentAlerts.GetActiveAlerts().ToList();
               
// create an <item> node for each alert
               
// ProcessAlertList(lAlerts);
               
foreach (Alert Alert in lAlerts)
               
{

                   
// grab values out of web service result row
                                     
                   
// create new RSS <item> with information from this alert
                    item
= new SyndicationItem(thisAlertTitle, thisAlertMsg, alertUri);
                   
// add item to the list
                    items
.Add(item);

               
} // end for each

               
               
           
}  // end try
           
catch (Exception ex)
           
{
               
//
           
}
               
                   
           
           
// add all items to the feed
            alerts
.Items = items;

           
// Return ATOM or RSS based on query string
           
// rss -> http://localhost:8732/Design_Time_Addresses/AlertSyndication/Alerts/
           
// atom -> http://localhost:8732/Design_Time_Addresses/AlertSyndication/Alerts/?format=atom
           
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
           
SyndicationFeedFormatter formatter = null;
           
if (query == "atom")
           
{
                formatter
= new Atom10FeedFormatter(alerts);
           
}
           
else
           
{
                formatter
= new Rss20FeedFormatter(alerts);
           
}

           
return formatter;
       
}
       
   
}
}

when i try to pull up the feed from outlook, it can't find the local server.  if i save the XML file, drop it on the server,  then point a reader to that XML file, it works fine. 

Original app.config (which works when i run locally)

 

 <services>
     
<service name="AlertSyndication.Alerts">
       
<endpoint address="Feed1" behaviorConfiguration="AlertSyndication.Feed1Behavior"
         
binding="webHttpBinding" contract="AlertSyndication.IAlerts" />
       
<host>
         
<baseAddresses>
           
<add baseAddress="http://localhost:8732/Design_Time_Addresses/AlertSyndication/" />
         
</baseAddresses>
       
</host>
     
</service>
   
</services>

 

This is how i modified the base address file (then i built the app and dropped in on the server)

 

 <services>
     
<service name="AlertSyndication.Alerts">
       
<endpoint address="Feed1" behaviorConfiguration="AlertSyndication.Feed1Behavior"
         
binding="webHttpBinding" contract="AlertSyndication.IAlerts" />
       
<host>
         
<baseAddresses>
           
<add baseAddress="http://www.mydomain.com/AlertSyndication/" />
         
</baseAddresses>
       
</host>
     
</service>
   
</services>

 

and when i enter the URL http://www.mydomain.com/AlertSyndication/Alerts  into the browser, i get 404 not found.  when i enter this address into a reader, it returns "cannot download because of problem connecting to the server"



Answers (1)