Getting Started with REST in WCF

Getting Started with REST in WCF

Hi All,
If you are planning to get started with REST in WCF, the following information might be helpful.
What is REST?
Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. As such, it is not strictly a method for building “web services.” The terms “representational state […]

Great videos from Pluralsight!

Great videos from Pluralsight!

Hi,
Pluralsight instructors have been doing great job!!! Not to mention the number of MVPs (Aaron Skonnard, Jon Flanders, Matt Milner..etc) from this single company! But here are a bunch of very useful introductory screencasts on WCF, Rest Services, ASP.Net MVP, etc. Check the pluralsight for more videos.
Ajax-enabling your WCF Services: http://www.pluralsight.com/main/screencasts/screencast.aspx?id=enabling-ajax-integration
Calling Restful Services: http://www.pluralsight.com/main/screencasts/screencast.aspx?id=calling-restful-services
Building Restful […]

Connect to WCF LOB Adapter hosted as WCF service using ClientCredentials

On the website http://msdn.microsoft.com/en-us/library/dd451003.aspx, we have a step by step guide to publish the Siebel adapter as a WCF Service in IIS and then have MOSS consume the data using that service. In this approach, credentials are pass by MOSS to the adapter using custom HTTP headers.


 


If instead you want to consume this service from a .net application or any client that wants to pass the credentials using the ClientCredentials object, this is how you will go about doing it. Follow the steps on http://msdn.microsoft.com/en-us/library/dd450994.aspx that gives detailed instructions about publishing the WCF service. There are 2 differences though


 


1.       In the “Configure service and endpoint behaviors” page, for “AuthenticationType” you will need to select “ClientCredentialUsernamePassword” (as opposed to “HTTPUsernamePassword” that the tutorial specifies)


 


 


 


2.       In the “Configure the service endpoint binding and address” page, click on the BindingConfiguration (the following BasicHttpBindingElement) to customize the binding. Set Security Mode to “TransportWithMessageCredential”


 


 


 


Follow the rest of the instructions for publishing the service. You can now connect to the service using a .net proxy application and pass the credentials using the ClientCredentials object.

Several custom scripting functoid with the same method

Hi all

A couple of months ago, while trying to solve the If-Then-Else issue within a map
in a nice way, a fellow BizTalk MVP suggested to me that I could just have the script
inside a custom scripting functoid and then copy the script from custom scripting
functoid to custom scripting functoid.

Naturally (as I assumed it was, back then) I told him that this was impossible, because
BizTalk wouldn’t let me have two custom scripting functoids which contains the same
method, ie. the two methods have the same signature.

“Sure you can”, he replied…. So I had to check it out… I fired up my BizTalk 2006
R2 virtual machine, and sure enough: He was right. I was in chock, because I was totally
sure i was right. so I fired up a BizTalk 2006 virtual machine and again; He was right
and I was wrong.

Now… those who know me will know that when I am convinced I am right, I will usually
go to great lengths to prove it 🙂 So I stepped down a version and tried BizTalk
2004. Again no luck.

But FINALLY, when trying it on BizTalk 2002, it turned out that I was right. Back
in BizTalk 2002, scripts were in VBScript and here you can not have multiple custom
scripting functoids with methods with the same signature. In versions after BizTalk
2002, the compiler will collapse those methods into one, but in BizTalk 2000 and 2002,
this is not done, and therefore an error occurs.

So all in all, I discovered this limitation back in 2003 and never questioned it again
since. So let this be a lesson to all (especially me, because I always think I am
right 🙂 ) – that sometimes we need to reevaluate what we think we know.

Hopefully this post will:

  1. encourage people to reevaluate opinions and knowledge
  2. inform others like me, who thinks that you cannot have the same method signature twice
    in a map, that this is wrong 🙂



eliasen

Sixeyed.Guidance.CodeGeneration: Technical Walkthrough

[Source: http://geekswithblogs.net/EltonStoneman]

The Code Generation Guidance Package on CodePlex was designed to be extensible and reusable. There are three main C# projects, which isolate logic for code generation, and the UI and GAX components.

Sixeyed.CodeGeneration

This is the core project, defining how metadata is represented and retrieved, and defining configuration for code generation runs. Metadata is defined in terms of:

  • A metadata source, which contains the logic for connecting to the source
  • A metadata provider, which uses the source to provide a list of available items, and to populate requested items
  • Metadata items, which are a representation of the metadata, typically using an appropriate .NET framework class

Code generation and UI logic always works on the interfaces which define these components, and the relationships between them:

In the Add Generated Items recipe, the available source types, sources and providers are populated from the collection of IMetadataSource objects held in the static SourceContainer class (additional sources can be added to the container at runtime using the SourceAssemblyConfiguration recipe argument – described in Sixeyed.Guidance.CodeGeneration Sample Package). When a provider is selected, GetItemNames is called to populate the list of available metadata items. When the selected items are iterated over in a code generation run, GetItem is called and the populated IMetadataItem is loaded as a property for the T4 template. The metadata item exposes the provider, and the provider exposes the source so the template can connect directly to the metadata if it needs to.

Each metadata interface has an abstract base class which implements it and contains core logic. For a given source, there may be an additional base class which abstracts logic common to that type of source. In Sixeyed.CodeGeneration.Metadata.Database.Source, DatabaseSource contains logic for accessing ADO.NET data sources in terms of IDbConnection and IDbCommand objects; SqlServerSource contains overriding logic to specify SqlConnection and SqlCommand usage – any additional database sources would do the same. Similarly for the SOAP metadata source, the logic for accessing WSDL is abstracted into a base class which may be used by other sources (e.g. a WCF specific source):

IMetadataProvider contains logic for accessing the source and retrieving a list of available items, and for populating a named item. The majority of logic is in the generic base class, so provider classes are quite simple. Simpler still are metadata item classes, which inherit the generic ItemBase class, specifying the underlying type of the item (XmlSchema in this case), without requiring any additional code.

Logic for populating template properties and executing T4 templates is located in the Guidance project rather than the code generation project, as it is dependent on the specific T4 engine being used.

Sixeyed.CodeGeneration.UI

The UI project contains generic user controls which represent metadata selections, and expose various events to notify of selection changes. The Guidance package Wizard uses these components rather than defining its own UI – the controls from this assembly allow code generation to be configured and invoked from a different UI host.

Sixeyed.Guidance.CodeGeneration

This project defines the GAX package and links together the code generation and UI components. The Guidance package is quite straightforward – it contains a single class AddGeneratedItems for the action of generating items from metadata and adding them to the selected project. The action expects SourceConfiguration, SelectedItems and TemplateConfiguration arguments; it connects to the source, iterates over the selected items and executes the template for each item.

To collect the argument values, there are custom wizard pages and value providers for each, allowing a recipe to provide ready-configured settings, or build a UI to gather them from the user:

  • Sixeyed.Guidance.CodeGeneration.CustomWizardPages. The custom Wizard pages use the static Metadata class to share state for the configured metadata source and provider. They override IsDataValid to determine if the page has collected enough information for the Wizard to proceed and the base class provides EnableNextStep which will advance the Wizard by enabling the Next or Finish button as appropriate. The base class will read the SourceAssemblyConfiguration recipe argument if provided, and use it to add any extra metadata assemblies at runtime.
  • Sixeyed.Guidance.CodeGeneration.ValueProviders. The value provider classes are straightforward, reading optional arguments from the recipe and populating the relevant metadata settings. Custom recipes can specify value providers to load settings instead of Wizard pages, so the Wizard UI can be restricted.

TODOs

There are a couple of minor changes I’d like to make to the current codebase:

  • Sixeyed.Guidance.CodeGeneration.CustomWizardPages.SelectTemplate defines its own UI, which should be moved to a user control in the UI project;
  • Sixeyed.CodeGeneration.Generation.MemberName contains methods for providing valid field and property names, but the Pascal and camel-case conversion is very basic;
  • Sixeyed.CodeGeneration.UI.SourceUri has some ugly hard-coding to decide which UI dialog it should show for different types of URI. It should be configurable, but I’m not happy moving it to an attribute of IMetadataSource, as that brings the UI into the core project.

And some additional metadata sources which I’ll add at a future point – a Clipboard source providing access to clipboard data through text or XML providers, and a BizTalk source which will use the ExplorerOM for providers supplying application, group and instance information as metadata.

A talk on profiling…

I’ll be giving a talk for Microsoft’s “Build Your Skills” event on March 24th in St. Louis (and March 31st in Minneapolis) on the topic of code profiling.  We’ll look at the profiling tools built into Visual Studio Team System Developer, and a few others to boot.  You can get all the details here. 
There is a whole slate of great talks planned for the day, so register now if you’re
in the area…