Common User Mistake in .NET 4: Mistyping the WF/WCF Service Configuration Name

Today I am presenting a common mistake that several folks have committed when using our latest .NET 4 bits. This user experience has its origin in the simplified configuration work developed in this upcoming version of the framework. I will summarize it with the following scenario.

Suppose you would like to write a new WCF Workflow Service Application using Visual Studio 2010. The configuration file that is added to your WF service when using this Visual Studio template makes use of the simplified configuration features in .NET 4, and thus it does not specify any <services> section to define endpoints for your WF service:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <system.serviceModel>

    <behaviors>

      <serviceBehaviors>

        <behavior>

          <serviceMetadata httpGetEnabled="true"/>

          <serviceDebug includeExceptionDetailInFaults="false"/>

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

</configuration>

Therefore, a set of default endpoints will be added to your service.

Now, imagine you would like to take advantage of the new WS-Discovery features and so make your WF service discoverable at runtime. In order to do that, you will need to add a ServiceDiscoveryBehavior and a DiscoveryEndpoint to your WF service. Since the most natural way to do this is via service configuration, you may want to expand the previous configuration to:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <system.serviceModel>

    <services>

      <service name="Service" behaviorConfiguration="ServiceBehaviors">

        <endpoint name="Endpoint"

                  address=""

                  binding="basicHttpBinding"

                  contract="IService" />

        <endpoint kind="udpDiscoveryEndpoint" />

      </service>

    </services>

    <behaviors>

      <serviceBehaviors>

        <behavior name="ServiceBehaviors">

          <serviceMetadata httpGetEnabled="true"/>

          <serviceDebug includeExceptionDetailInFaults="false"/>

          <serviceDiscovery />

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

</configuration>

This service configuration look probably reminds you of what you previously had to write to develop your web services in .NET 3.5 using WCF.

In order to make sure your service is ready to be deployed, you can press CTRL-F5, and then select Service1.xamlx. The following unexpected screen appears:

 

 

Why is the metadata publishing currently disabled? Looking at the configuration file, the service we just opened seems to have a ServiceMetadataBehavior with the httpGetEnabled property set to true. Why is this not working properly then?

If you take a closer look at the configuration file, you may realize about the following: the default service name in the WCF Workflow Service Application template is Service1, and not Service. After changing the service name in the configuration file to be Service1, and pressing CTRL-F5 again, you will now be able to see the following:

 

 

The correct configuration has been added to your service!

What we have experienced here is the result of mistyping your service configuration name. When the service was opened, since no explicit configuration was found for it, a default set of endpoints with no default service behaviors was added to your service, and that is why the metadata publishing was not being enabled.

In .NET 3.5, the user experience was an InvalidOperationException thrown when a service was to be open to indicate that it “has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.” However, due to the simplified service configuration work in .NET 4, this will not be the case in the upcoming version of the framework, and users will need to make sure that the proper configuration (e.g., security, encoding, etc.) is correctly added to their services.

We are currently thinking on different ways to mitigate this. Adding design time configuration validation seems to be the best solution so far. Opinions?

 

Preparing for PDC 09

I’ll be there. I’m happy about it. The sessions looks promising, although I have to say that the functionality of the website as far as scheduling goes really blows. There it no way to visualize your schedule, and no way to export it to your outlook calendar or even to something like Excel. That I’ve found to this date.

There are three sessions awarded with the BizTalk keyword (listed in my order or interest):

Microsoft BizTalk Server Futures and Roadmap

Learn how BizTalk Server 2009 lets you focus on writing the code to do the hardcore business logic and let BizTalk take care of moving the data. Hear how your development skills with Windows Communication Foundation (WCF), and Windows Workflow Foundation (WF) work seamlessly with the powerful integration platform of BizTalk. Find out how BizTalk aligns with the Microsoft application server in the longer term.

Queuing and Publish/Subscribe in a Heterogeneous Environment

Queuing and publish/subscribe are common patterns for building loosely-coupled, distributed applications. Learn how to use Microsoft Windows Communication Foundation (WCF) the new Microsoft ASP.NET 4.0 routing service, the Microsoft .NET Service Bus, and Microsoft BizTalk Server to easily connect heterogeneous systems. We then introduce AMQP (the Advanced Message Queuing Protocol), an important new open standard for interoperable message-oriented middleware, which will reduce the friction in connecting heterogeneous clients. A real-world scenario shows AMQP in action, connecting WCF, Microsoft Excel, and Java-based clients.

Connecting Applications with the Microsoft BizTalk Enterprise Service Bus

See how the BizTalk Enterprise Service Bus (ESB) enables you to build services that can be quickly located and connected, whether they live behind the firewall or in the cloud, without creating a brittle point-to-point link. Learn how to dramatically improve the service lifecycle of development, testing, and deployment by using the powerful messaging, routing, and transformation capabilities of the BizTalk ESB in your solution today, and get a glimpse of future plans for BizTalk service bus/pub-sub pattern

BizTalk 09 and SQL R2 not Supported\BizTalk 09 and Project References

In a recent case the customer was attempting to install BizTalk 09 with SQL 2008 R2. It fails with the following error.

“Failed to create Management database ‘BizTalkMgmtDB’ on server ‘XXXXX’. Error ‘0x80040E1d’ occurred.”

The server name is represented by the “XXXXX”.

 

 

No follow up has been done to explain the problem. The BizTalk 09 product site does not mention support for this version of SQL.

Building Projects with BizTalk 09

Beware when building projects with BizTalk 09. There is a problem with references. There are various manifestations of the problem. Artifacts from referenced projects may not be available. Messages types requiring a reference to another project may not be available. Maps requiring schemas from referenced types are not available. The hot fix is under development and should be available in the near future. This could be a bigger problem as more symptoms are discovered. One fix may not fit all.

Win 7/Win2008 R2 – something I don’t understand

Guys – something that always gets me.

Q. Why when you install Win2K8/R2 out of the box settings have the POWER MODE=balanced???

I’m always amazed by this – there’s 101 other questions + answers you’re asked and
you give. But nowhere does the system say (oh a server system mind you)

“BTW – you know the 8 Cores you have, you’re gonna use 2 of them at any one time”

It’s a Server O/S not a desktop (Desktop I can totally understand
– saving power, greener world etc etc) – server I don’t get.
(The flip side to that coin is – “if the server actually ran at a faster capacity
– I’d be finished in 30 mins instead of 4hrs” -> therefore you save 3.30mins of
green lush rainforest – or some nuclear radiation from entering the world)

I find this power setting is always one of those elusive settings on Server, upon
first start up you get prompted for Roles, Features, Networking even IE
Security Settings
.but nothing about limping along.

You have been warned – you may think “What’s Mick on about”did I tell you about the
TWO production environments I recently visited and they thought I was a miracle worker

I wonder is SCOM 2007 R2 reports that setting back to the main console??

Oh BizTalk, why dost thou mock me?

In any given integration project many different parties are involved. In some cases these parties have standard endpoints against which BizTalk operates and sometimes these endpoints are built as you go in the participating systems to meet a new demand. This is true for other types of projects as well – things get finished at different times – and you need to be able to work independent of each other during that time. What you often do determine very early in the project are the design of messages, schemas or APIs through which you exchange information. In many cases a BizTalk project can effectively use FILE send or receive ports that serve the same purpose as a One-Way send or receive port to say SAP would do at a later stage. But how about solicit-response send ports? What do you exchange these for?

In this post I’d like to introduce a way to handle solicit-response through the use of a catch all WCF Service. There any many ways in which to mock a service. The prime benefit with this approach is that you will be able to model your BizTalk solution the way you want it to be, without having to have access to the real service, and exchange the solicit-response port for it’s production or acceptance test counter parts at your convenience.

To achieve this we need something that let’s us send in any message, and based on some part of the message determine what message to send back, and the send it as a response.

WCF is a perfect candidate. It has functionality both to allow us to create methods that handles all incoming requests by specifying a wildcard (*) as the Action property, and accept any message and can send any message as a return. Using the Message base class it also allows us to easily create the response message, and populate the body of the message from the contents of a stream, such as a file (See the ’Creating Messages from XmlReaders’ topic in the link).

So what I did was I created a WCF Service, and added a method to catch all messages:

[OperationContract(Action = "*", ReplyAction="*")]
Message CatchAll(Message message);

In the implementation for this method I have include the following code:

FileStream stream = new FileStream(ResponseHelper.GetResponseFile(requestAction), FileMode.Open);
XmlDictionaryReader xdr = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas());
MessageVersion ver = OperationContext.Current.IncomingMessageVersion;
return Message.CreateMessage(ver, ResponseHelper.GetResponseAction(requestAction), xdr);

I have a small helper class that just helps me get data from the config, the config in turn looks like this:

<configSections>
  <section name="requestResponseHandling" 
type="ServiceHost.RequestResponseHandlingConfigSection, ServiceHost"/>
</configSections>

<requestResponseHandling>
  <actionList>
    <add requestAction="http://tempuri.org/IService1/GetData2" 
responseAction="http://tempuri.org/IService1/GetData2Response"
responseLocation="GetData2Response.xml" />
  </actionList>
</requestResponseHandling>

This enables me to add new responses to incoming requests without needing to rebuild the service to incorporate a new response. You could go crazy here with code and undertakings to reply based on some context or what not. In the case presented here I’m just making it simple and returning the same static message for all request that matches a certain requestAction.

Finally, put this in the host of your choice. In my case I’ve got IIS so I’m hosting it there. That will also cause changes to the web.config to automatically get loaded, so that’s happy times.

Using this from a client is super easy. Just point the address of the client endpoint towards this service instead. The only thing that might not be super simple (though still fairly simple) is that you need to know what the meat of the response will look like when serialized as a response (the body of the response message). That is you need to Generate a sample response message from your wsdl.

Now let’s look at how we can utilize this to mock services in BizTalk Server. Oh, but wait, that sounds like it would be a bit of work to do, but no, that isn’t the case. In fact, once you have configured the WCF service the only thing you need to do is to point your Send port at this service instead of the system that would otherwise be there in it’s place. Loop closed.

Interviews at ØreDev and Ze Frank!

Tibi and I are winding down after a hectic few days at the %u00d8reDev conference in Sweden. It was a great conference, with a lot of international speakers and attendees, and a good mix of technologies and tracks. One of the highlights was Ze Frank, who was delivering his stand up comedy routine, which was targeted just right for the attendees.
I laid down the gauntlet to Tibi by challenging him to get an interview with Ze, and he accepted and delivered the goods, thanks to Herbj%u00f6rn Wilhelmsen for chatting with Ze to arrange it. We managed to get a slightly longer “5 Minutes With” interview in which Ze turned the tables on Tibi and asked him questions about conquering a fear of flying and his attitude for dealing with the challenges life can throw at us. It’s very refreshing to have an interview without any three-letter-acronyms.
CloudCasts has also had a busy week, as I’ve posted interviews with Scott Hanselmam, Scott Allen, Julie Lerman, Herbj%u00f6rn Wilhelmsen and Magnus M%u00e5rtensson. We even added some music to the site with a splendid rendition of “The Joker” by Carl Franklin, with Shawn Wildermoth providing the guitar solo. If you are ever in Malm%u00f6, I recommend the “The Bishops Arms”, though we could not decide if we should have 8 or 10 Bishops Fingers there. I have another few videos in the can, and will be getting them uploaded over the weekend.
Overall %u00d8reDev 2009 was a great success, big credit to Michael Tiberg for his organization skills and his passion for the event; I’m looking forward to %u00d8reDev 2010 already.
You can see all the %u00d8reDev content here.
To DAL or not to DAL

To DAL or not to DAL

Do BizTalk consultants need to care about Data Access Layers? Does a BizTalk solution really need a DAL?  These are the questions that I’ve been mulling over in the past few weeks. Let me explain.

There are a couple of places where a BizTalk solution encounters a DAL. The first is where the DAL acts as […]