WCF 3.5: SyndicationFeedFormatter and UriTemplate samples

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

 

Example 1

 

[ServiceContract]
 [ServiceKnownType( typeof( Atom10FeedFormatter ) )]
 [ServiceKnownType( typeof( Rss20FeedFormatter ) )]

 public interface IGpsService
 {

    [OperationContract]

    [WebGet(UriTemplate ="GetCoordinates/{format}/{maxcount}/{dayspan}")]

    SyndicationFeedFormatter GetItems(string format,
                                      string maxCount,
                                      string daySpan);
 }

 

Request sent from client:

http://localhost:8081/feed/getcoordinates/atom/100/22

Results in Immediate window

WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BoundVariables.AllKeys
{Dimensions:[3]}
    [0]: "FORMAT"
    [1]: "MAXCOUNT"
    [2]: "DAYSPAN"

WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BoundVariables["FORMAT"]
"atom"

WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BoundVariables["MAXCOUNT"]
"100"

WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BoundVariables["DAYSPAN"]
"22"

 

Example 2

[ServiceContract]
 [ServiceKnownType( typeof( Atom10FeedFormatter ) )]
 [ServiceKnownType( typeof( Rss20FeedFormatter ) )]

 public interface IGpsService
 {

    [OperationContract]

    [WebGet(UriTemplate ="GetCoordinates?{format={format}")]

    SyndicationFeedFormatter GetItems(string format);
 }

Request sent from client:

http://localhost:8081/feed/getcoordinates?format=rss

Results in Immediate window

WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters.AllKeys
{Dimensions:[1]}
    [0]: "format"


WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]

rss


Posted Jun 18 2008, 11:54 AM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.