FRIDAY, MAY 09, 2008




MY ACCOUNT LOGIN

LOGIN NAME:

PASSWORD:

REGISTER TODAY!
FORGOT YOUR PASSWORD?
TRY ALL WEB SERVICES
FREE FOR 30 DAYS!

WEB SERVICES

XWEBEMAILVALIDATION [tool]

XWEB1003 [real estate]

XWEBACHDIRECTORY [financial]

XWEBCHECKOUT [ecommerce]

XWEBTD [ecommerce]

XWEBNEWS [content mgmt.]


ANNOUNCEMENTS


NEW IMPLEMENTATION GUIDE AVAILABLE: "XWEBBLOG CLIENT 2.0”

XWEBBLOG VERSION 2 LAUNCHED

XWEBBLOG WEB SERVICE NOW FEATURES SSL SECURITY

NEW IMPLEMENTATION GUIDE AVAILABLE: "HOW-TO SYNDICATE (RSS 2.0) YOUR WEBLOG ENTRIES USING XSLT"

NEW IMPLEMENTATION GUIDE AVAILABLE: "HOW-TO DISPLAY BLOG ENTRIES POSTED WITHIN A SPECIFIC DATE RANGE"



Web Services, SOA Solutions, SOA Services - XWebServices.com


HOME

WEB SERVICES

SOA SOLUTIONS

SOA SERVICES

ABOUT US





XWEBBLOG


Documentation


FAQs


Implementation Guides


Forum


Pricing






SEARCH









HOME  ::  WEB SERVICES  ::  XWEBBLOG  ::  IMPLEMENTATION GUIDES

:: Web Services :: XWebBlog :: Implementation Guides ::

How-To Syndicate (RSS 2.0) Your Weblog Entries Using XSLT

The procedures in this implementation guide require that you have some knowledge of XML, XSLT and ASP.NET web development with the Microsoft Visual Basic.NET development tool.

The steps in this "how-to" implementation guide are:

To download the source code for this "how-to" implementation guide, as well as for additional hints and tips, please read our Final Notes.

Add a "Web Reference" to the XWebBlog Web Service

  • In your web project, add a Web Reference to the XWebBlog web service. Here are 2 ways you can accomplish this:

    • Browse the Solution Explorer, right click on References and select Add Web Reference... from the drop down menu.
    • From the File Menu, select Project - Add Web Reference....
  • The Add Web Reference pop-up window will open. In the URL textbox, enter the following URI:

    http://ws.xwebservices.com/XWebBlog/XWebBlog.asmx?wsdl

  • Hit the Enter key or click the Go button located to the right of the URL textbox.
  • Change the Web reference name to XWebBlog for easier reference.
  • Click the Add Reference button to complete this step.

Add a "Web Form" to the Web Application

  • In your web project, add a Web Form. This Web Form will contain the RSS Feed we will use for syndicating the Blog Entries. Here are 2 ways you can accomplish this:

    • Browse the Solution Explorer, right click the name of your project, and select Add - Add Web Form....
    • From the File Menu, select Project - Add Web Form....
  • Change the Name textbox in the Add New Item pop-up provided to rss.aspx.

Write code in the "Codebehind" of the web form to retrieve the Blog Entries by consuming the XWebBlog Web Service

Based on the documentation for the XWebBlog web service, in order to successfully consume the web service, we will need to authenticate first using SOAP Headers. Here's how:

  • Open the "Codebehind" of the rss.aspx web form we added to the web project in the previous step.
  • Since the web service requires SOAP Headers for authentication purposes, we must first create a new instance of the class representing the SOAP Header and then populate the SOAP Header values:

    ' handle authentication
    Dim objAuth As New XWebBlog.AuthHeader
    objAuth.LoginName = "<my_login_name>"
    objAuth.Password = "<my_password>"

    NOTE***: Instead of hard-coding the LoginName and Password values, you may want to dynamically read them from the web.config file (LOGIN_NAME and PASSWORD must be added to the <AppSettings> section of the web.config file):

    objAuth.LoginName = System.Configuration.ConfigurationSettings.AppSettings("LOGIN_NAME")
    objAuth.Password = System.Configuration.ConfigurationSettings.AppSettings("PASSWORD")

  • Next, we need to create a new instance of the proxy class and assign the SOAP Header object to the member variable of the proxy class representing the SOAP Header:

    'create the XWebBlog web service proxy
    Dim objBlog As New XWebBlog.XWebBlog
    objBlog.AuthHeaderValue = objAuth

  • We are now ready to call the method on the proxy class that communicates with the Web Service method and returns the Blog Entry records we want in the RSS feed. For this how-to guide we chose to display the last 5 Blog Entries we posted:

    'store the result in a variable
    Dim strBlogXML As String = objBlog.LoadBlog(1, 5)

Implement an XML Web Control to display the Weblog Entries

In the "Codebehind" of the rss.aspx web form, we need to declare an XML Web Control. Next, we need to set its DocumentContent property to the XML string we received from the SOAP method. Finally, we set the TransformSource property to the path of an XSL Stylesheet (please click here for an example) that will transform the XML string into the RSS 2.0 format we desire:

  • Declare the XML Web Control in the Codebehind:

    Protected xmlBlog As System.Web.UI.WebControls.XML

  • Set the XML Web Control's DocumentContent property to the XML string from the previous step:

    'set the DocumentContent property
    xmlBlog.DocumentContent = strBlogXML

  • Set the XML Web Control's TransformSource property to the path of the XSL Stylesheet (substitute your own path):

    'set the TransformSource property
    xmlBlog.TransformSource = "blog.xslt"

The last thing we need to do in the "Codebehind" is set the web form's ContentType property to "text/xml" and the ContentEncoding property to UTF8:

Response.ContentType = "text/xml"
Response.ContentEncoding = System.Text.Encoding.UTF8

The only thing in the HTML Editor of the rss.aspx web form should be the declaration for the XML Web Control:

<asp:XML ID="xmlBlog" Runat="server" />

Final Notes

The source code for this "how-to" implementation guide can be downloaded by clicking the link below (zip file, contains the source code for all "how-to" implementation guides for the XWebBlog Web Service)

XWebBlogClient.zip

You may use the other SOAP methods exposed by the XWebBlog web service to syndicate all your Weblog Entries or Blog Entries posted within a specific date range (archive).

The XWebServices.com portal implements the technique outlined in this "how-to" implementation guide in all our RSS Feeds.

It's always good practice to implement a Try...Catch... error handling technique to handle some or all possible errors that may occur while the code is executing. We strongly recommend that you implement such a technique.



HOME
WEB SERVICES
SOA SOLUTIONS
SOA SERVICES
MY ACCOUNT
ABOUT US