-
March 21st, 2011, 01:42 PM
#1
WCF App to Write out RSS
hey,
Platform is .NET 4.0 Framework, starting with template: Syndication Service Library. will be running in production on MS Server 2008/IIS 7
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 a few broad issues. The one I have to resolve first is:
1) i can't get the code to run on the production web server [win 2008/iis 7] (it only runs on my local machine)
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". when i try to enter the localhost URL from a reader, it returns an error on connection to 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.
Code:
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_Ad...cation/Alerts/
// atom -> http://localhost:8732/Design_Time_Ad...s/?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;
}
}
}
Original app.config (which works when i run locally)
Code:
<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)
Code:
<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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|