Azure AppFabric Service bus, Silverlight Integration – End-to-End (walkthrough) – Part 2

Introduction

In part 1 we setup the scene by creating a simple Silverlight/WCF application. In that application the Silverlight application is initialized, it made a call to the underlying WCF service operation "GetWelcomeText" and displayed the text on the UI. We used the basicHttpBinding to establish communication between the SL client and WCF service. In this part, we are going to make some modifications to the configuration files, IIS/Windows Server AppFabric settings and make the application work across boundaries between two different geographical locations using Azure AppFabric Service Bus. The high level picture is going to look like

Source: http://blogs.digitaldeposit.net/saravana

Prerequisite:

One of the challenges of Silverlight and Azure AppFabric service bus integration is configuring access to the clientaccesspolicy.xml file. I’ve explained in detail, how you can resolve it in this blog post. It’s mandatory to complete the procedure explained in that post, before you proceed further.

It’s also mandatory to have IIS/Windows Server AppFabric to complete this walkthrough. Please download and install it from http://www.microsoft.com/download/en/details.aspx?id=15848

Create Service Endpoint Behaviour

Expand "Advanced" and "Endpoint Behavior" from the navigation tree and click on the link "New Endpoint Behavior Configuration" as shown below

Click the "Add" button, which will bring "Adding Behavior element extensions" screen as shown below. From the list select "transportClientEndpointBehavior" and click "Add".

Change the name to "slsb_ServiceEndpointBehavior". The final screen should look as shown below

Double click on transportClientEndpointBehavior from the list and make sure CredentialType is SharedSecret.

Create a basicHttpRelayBinding

Navigate to "Bindings" and select "New Binding Configuration.." as shown below

On the "Create a New Binding" window select "basicHttpRelayBinding" and click OK as shown below.

Change the name to slsb_basicHttpRelayBinding, the final configuration should look as shown below.

Create a new Endpoint

Now we are going to create a new WCF end point using the endpointBehavior and basicHttpRelayBinding we created in previous steps.

Navigate to Services\Endpoints, right-click and select "New Service Endpoint" as shown below.

Once the properties window is displayed, provide the configurations as shown below.

The modified web.config file is going to look as shown below

We are going to make few changes here, which we couldn’t do on the SvcConfigEditor.exe tool. The modified web.config file is going to look as shown below

The objective for this demo is establishing communication between Silverlight application and remote WCF service via Azure AppFabric service bus. So, we are going to ignore all the security settings for now, which I’ll cover in future articles. Things to note

Security is set to "None"

Endpoint address is using "http" (not "https")

Also, I commented out previous local endpoint configurations and things that are not really relevant for this demo to keep it simple.

Configure Virtual Directory in IIS/Windows Server AppFabric

You’ll need Windows Server AppFabric for this demo to work, which you can download from http://www.microsoft.com/download/en/details.aspx?id=15848

We are going to host our WCF service on IIS/Windows Server AppFabric. The main reason for that is, we need to take advantage of the "Auto Start" functionality of IIS/ Windows Server AppFabric to start our WCF service automatically when IIS starts and register its namespace in the Azure AppFabric Service bus. Previously this was one of the challenges, since the WCF services hosted just on IIS (without AppFabric) won’t get started until the first request hit the service. In this section we will see the configuration required on IIS/Windows Server AppFabric for our WCF service.

Start Internet Service Manager, and click on our virtual directory AppFabricSBandSLIntegration.Web.

On the Actions column, under "Manage WCF and WF Services", click on "Configure" as shown below

Select "Auto-Start" and choose the option "Enabled" as shown below.

After closing the window, you can Start the application, as shown in the below figure.

Reset IIS by opening a command prompt as administrator and typing iisreset. Navigate to our WCF service as shown below and make sure there are no errors and it displays the page as shown below

One of the common errors I’ve seen, especially while working on corporate networks where a proxy server is used is

Unable to reach watchdog.servicebus.windows.net via TCP (9351, 9352) or HTTP (80, 443)

The solution for the problem is simple, on the web.config file just configure the proxy details as shown below.

<system.net>

<defaultProxy useDefaultCredentials="true">

<proxy proxyaddress="http://<your proxy>:<your port>"/>

</defaultProxy>

</system.net>

You also need to make sure the virtual directory is configured to run under an IIS application pool, with the identity that access to proxy server.

Update the Silverlight application to point to Azure AppFabric service bus URL

The final change we need to make is to update the Silverlight application configuration file ServiceReference.Clientconfig.config file with url pointing to the Azure AppFabric service bus url as shown below

Press F5 to run the application, and now you should see the application working as before but this time via the Azure AppFabric service bus.

One of the key things to note here is, on the Silverlight client side, I only modified the address in the endpoint element. That’s because basicHttpBinding is compatible with basicHttpRelayBinding.

The other important thing is, we relaxed the security completely and concentrated only on connectivity for this demo. So, don’t use this configuration in production.

Nandri!

Saravana

Azure AppFabric Service bus, Silverlight Integration – End-to-End (walkthrough) – Part 1

Introduction

In this article we are going to see the end to end integration of Azure AppFabric Service bus and Silverlight. First we are going to create a very basic "Hello World" Silverlight application that interacts with a WCF operation called "GetWelcomeText" and displays the text returned in the UI. In order to explain the core concepts clearly, we are going to keep the sample as simple as possible. The initial solution is going to look as shown below. The SL application hosted on a local IIS/AppFabric(server) web server and accessed via a browser as shown below.

 

Next, we are going to extend the same sample "Hello World" example to introduce Azure AppFabric service bus as shown in the below picture and show the power of AppFabric Service bus platform, which enables us to use the remote WCF services hosted geographically somewhere in the wild.

Original Source: http://blogs.digitaldeposit.net/saravana

The first part of the article doesn’t going to touch anything on Azure AppFabric service bus, it’s all about creating a simple SL/WCF application.

Create a Hello World Silverlight Application

Open Visual Studio (use Run as Administrator), and Click New Project from the Start page, which will bring the "New Project" window as shown below

Select Silverlight from Installed Templates, and choose "Silverlight Application" from the list. Provide "AppFabricSBandSLIntegration" as the name and click OK. In the next screen ("New Silverlight Application"), just leave the default values and click OK. The solution structure will look as shown below.

Add a simple WCF service:

Right click on AppFabricSBandSLIntegration.Web ASP.NET application and select "Add New Item", which brings the "Add New Item" window as shown below.

Select "Web" from Installed templates and "WCF Service" from the list provide "AdminService.svc" as the name and click "Add".

Next, rename the default method name "DoWork" to "GetWelcomeText" and changed the return type from "void" to "string" both in IAdminService.cs and AdminService.cs files. The implementation now looks as shown below.

Rebuild the solution by pressing Ctrl+Shift+B.

Convert the web application to use IIS:

By default the ASP.NET web application will be configured to run on a local server (cassini), for our demo we are going to configure it to run under IIS/AppFabric(server). Right click on the AppFabricSBandSLIntegration.Web project, select "Properties". In the properties windows select "Web" from LHS and select the option "Use Local IIS Web Server". Click on "Create Virtual Directory" button to create the virtual directory and click OK on the popup window (you must have opened Visual Studio by Run as Administrator; else this step will give error.)

Build the solution by pressing Ctrl+Shift+B, and navigate to http://localhost/AppFabricSBandSLIntegration.Web/AdminService.svc and make sure no errors encountered.

Configure web.config file with appropriate WCF settings

For this step we are going to use the WCF service configuration tool SvcConfigEditor.exe. Open a Visual Studio command prompt and type SvcConfigEditor.exe. Once the application is opened, click File/Open and navigate to web.config file found under AppFabricSBandSLIntegration.Web folder.

Click on "Create a New Service" link and click the browse button. Navigate to AppFabricSBandSLIntegration.Web/bin/ AppFabricSBandSLIntegration.Web.dll and select AppFabricSBandSLIntegration.Web.AdminService once selected the screen should look as shown below

Click on the "Next" button in the wizard and make sure the contract is selected as shown below.

Click "Next", On "What communication mode is your service using?" option select "HTTP"

Click "Next", On "What method of interoperability do you want to use?" option select "Basic web service interoperability"

Click "Next", On "What’s your address of your end point", clear http:// and click "Yes" on the warning.

On the final summary screen, click "Finish". Your web.config file will now look as shown below.

Rebuild the solution by pressing Ctrl+Shift+B. Right click on AdminService.svc file and select "View in Browser". Make sure it displays as shown below without any errors.

Now we have completed all the required stuff on the WCF services side, let’s move on to the client side Silverlight application.

Prepare the Silverlight application to communicate with the WCF Service.

Add Service Reference:

The very first step is to create the service reference to our AdminService.svc WCF service. Right click on the AppFabricSBandSLIntegration Silverlight project and select "Add Service Reference", which will bring the window as shown below.

Paste the url of our AdminService.svc file and click "Go". Once the service is resolved, provide "AdvancedServiceReference" as the namespace and click "OK".

The above step should automatically add ServiceReference.ClientConfig file to the AppFabricSBandSLIntegration Silverlight project as shown below.

Open the MainPage.xaml file and add a TextBlock as shown in the below snippet.

Open the MainPage.Xaml.cs file and add the following lines of code. Basically we are instantiating the proxy client, hooking up the "Completed" event and call the asyn method GetWelcomeTextAsync. Once we receive the response from WCF service, SL runtime will automatically execute the code present in the event handler. We are simply displaying the "Hello World from WCF Service" text returned from WCF service in the text block we created in the previous step.

At this stage everything is completed and pressing the "F5" button should execute the ASP.NET/Silverlight application and display the following result

In part 2 of the article, we’ll see how we can introduce Azure AppFabric Service bus in the middle between the Silverlight client and the WCF service. You may be wondering, why I have used the SvcConfigEditor.exe to configure the WCF service rather just simply asking the user to paste 4 lines of configuration Xml. The main reason for using the tool is, when we modify the configuration for Azure AppFabric Service Bus, it makes it easy to understand all the available configuration options.

Nandri

Saravana Kumar

Warning – Cannot resolve the ’schemaLocation’ attribute

Warning – Cannot resolve the ’schemaLocation’ attribute

I always take compiler warnings seriously and at least investigate them before releasing. In one of the solutions I work on I consequently received the warning ’Cannot resolve the ’schemaLocation’ attribute’. This solution contains a BizTalk project with a lot of schemas. For each schema multiple occurrences of this warning where reported. This lead to […]
Blog Post by: Randal van Splunteren

Silverlight – Breakpoint will not currently be hit. No symbols loaded for this document.

Just a quick tip, when you are trying to debug a Silverlight application by putting break point in the Silverlight code and you see the message "Breakpoint will not currently be hit. No symbols loaded for this document." with a hallow icon and warning symbol.

The reason for this is, Silverlight debugging is not enabled on the web application hosting the Silverlight XAP file. You can fix this easily by going to  "Properties" of the web application, choose "Web" from LHS tab, and under Debuggers section select the check box "Silverlight".

Nandri!

Saravana

Exception: System.EnterpriseServices.TransactionProxyException

I get an exception when configuring BizTalk 2010.

BizTalk application server.

Separate SQL server for the databases.

Exception: System.EnterpriseServices.TransactionProxyException

Looking at http://support.microsoft.com/kb/293799

When a System.EnterpriseServices.TransactionProxyException exception is triggered during a transaction completion, it cannot be caught from other application domains. Instead, you receive a System.Runtime.Serialization.SerializationException exception that resembles the following:

Unhandled Exception: System.Runtime.Serialization.SerializationException: Type ‘System.EnterpriseSer vices.TransactionProxyException’ in Assembly ‘System.EnterpriseServices, Version=2.0.0.0, Culture=ne utral, PublicKeyToken=b03f5f7f11d50a3a’ is not marked as serializable.

Gave me a hint to the problem, however was not the solution or any where near to it be careful following this I did not.

I saw that the databases were created during the configuration, and then deleted; only leaving the management database in a weird state. So the communication to the database server was fine.

I did some more investigation and found the dtctester tool great for testing if my dtc was set up correctly, as this is one thing that BizTalk leverages extensively.

I ran the ‘dtctester’ tool, and it came up with the following:

Executed: dtctester.exe

DSN: PMS

User Name: *******

Password: ********

tablename= #dtc16032

Creating Temp Table for Testing: #dtc16032

Warning: No Columns in Result Set From Executing: ‘create table #dtc16032 (ival

int)’

Initializing DTC

Beginning DTC Transaction

Enlisting Connection in Transaction

Error:

SQLSTATE=25S12,Native error=-2147168242,msg='[Microsoft][ODBC SQL Server Driver]

Distributed transaction error’

Error:

SQLSTATE=24000,Native error=0,msg=[Microsoft][ODBC SQL Server Driver]Invalid cur

sor state

Typical Errors in DTC Output When

a. Firewall Has Ports Closed

-OR-

b. Bad WINS/DNS entries

-OR-

c. Misconfigured network

-OR-

d. Misconfigured SQL Server machine that has multiple netcards.

Aborting DTC Transaction

Releasing DTC Interface Pointers

Successfully Released pTransaction Pointer.

Ok, so my problem was DTC.

I found a great response to a similar problem that told me to look at a couple of DTC issues. (http://dbaspot.com/sqlserver-server/215054-msdtc-doesnt-seem-work.html)

http://support.microsoft.com/kb/817064

http://support.microsoft.com/kb/301600

If you are running Win2K3 SP1, you will need to reset the DTC security parameters:

http://support.microsoft.com/kb/899191

Since you are beginning the transaction on a remote host, that host will also need to properly configure its DTC services.

Finally, if the communication must transit any firewalls, then you will need to restrict RPC ports on both Client and Server for Internet Ports, and then authorize these Ports in the firewall ACLs.

http://support.microsoft.com/kb/300083

http://support.microsoft.com/kb/250367/EN-US

I checked the firewall, no problem, I checked the other things, and made a change to the DTC security not via the method mentioned but via the component services.

Everyone should know by now to change the security settings under component services for the dtc on the sql server and the BizTalk server.

Go to the Component services/My Computer/Distributed Transaction Controller/LocalDTC

Properties/security

Ensure that everything in here is checked, (Remote admin is optional)

I usually select no Authentication required, and ensure that the network service account is running the service.

I did this, thinking I’ve found the problem..

Nope same problem re occurs

I find out that the SQL server is clustered, so I go to the cluster manager, and look at the dtc settings, and open the localdtc from there, the same thing, all the settings are correct because I had already changed them.

Then I notice, CLUSTER DTC, and expand that and mange that. The cluster has its OWN instance of DTC, of course, it does not use the local DTC at all.

I look at the security settings of the cluster DTC, and change those to match, and wolla it works. Nice to know if the SQL server is clustered

Always look at DTC, if your BizTalk does not wish to install to a remote SQL server.

Sorting out AppFabric Service bus, Silverlight and Clientaccesspolicy.xml issue -hidden gem in Azure AppFabric SDK CTP 2.0

By default Silverlight applications are allowed to access resources (services) only from the location from where they originated. From Silverlight 2.0 support was included to access services from a remote server (cross-domain), as long as the remote server allows the Silverlight application to access it. This gave administrators more control on who is accessing the resource, and can impose certain restrictions.

The security policy system in the Silverlight runtime requires that a policy file (clientaccesspolicy.xml) be downloaded from a target domain before a network connection is allowed to access a network resource under that target domain.

Basics:

When a connection request is initiated from Silverlight application, the SL runtime tries to download the security policy file using the HTTP protocol. The SL runtime first tries to download a SL policy file with the name “clientaccesspolicy.xml” at the root of the requested target domain using HTTP protocol. If it can’t find “clientaccesspolicy.xml” file, it will try and download “crossdomain.xml” file, which was developed by Adobe for Flash. Both the files are recognised by SL runtime.

If the policy file retrieved is successfully parsed and grants permission, a connection is finally opened to the target host. If the policy file retrieved is invalid, the connection to network resource is denied by SL runtime. For more information on policy file please refer to http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx

Challenge with AppFabric Service bus

From the above AppFabric Service bus architecture picture, we can imagine your SL application is running on the LHS (on-premises). The WCF services that the SL application dependant on is deployed on the RHS (on-premises). The communication between the SL and WCF deployed on two geographically separate premises are connected using the Windows AppFabric Service bus.

The important point to note here is the SL application is not going to originate/reside in the same location as the WCF services (RHS on-premise). The SL application would have originated from different source, may be from a local web server on the LHS on-premise. So for the SL runtime the WCF services are from a different domain and cross-domain security policy file (clientaccesspolicy.xml/crossdomain.xml) is required to establish a connection.

Here comes the challenge, as explained in the basics topic earlier. The SL runtime is going to look for clientaccesspolicy.xml file on the root of the requested target domain. In the AppFabric Service bus case, the root is actually the Service bus namespace. Ex:

http://yournamespace.servicebus.windows.net , not the actual location of WCF services on the RHS on-premise. The SL runtime will try to make a HTTP request, equivalent of

http://yournamespace.servicebus.windows.net/clientaccesspolicy.xml

And since that file is not available in that location, it will throw a security exception and won’t allow any further network connection.

Previous hacky solutions:

So far developers tackled this challenge by creating a REST service on the WCF RHS on-premise covering the root URL, something as shown below.

[ServiceContract]

public interface IClientAccessPolicy

{

[OperationContract]

[WebGet(UriTemplate = “clientaccesspolicy.xml”)]

Message GetPolicyFile();

}

Few examples:

http://blogs.u2u.be/peter/post/2011/02/08/Silverlight-and-the-Windows-Azure-AppFabric-Service-Bus.aspx

http://code.msdn.microsoft.com/CSAzureServiceBusSLRest-41878c00

One of the challenges with this approach is you need to make sure you register the REST service at the end, after registering all your real WCF services. Since the REST service is at the root and it doesn’t have a unique URI, registering it first will result in taking the complete namespace and trying to register any other services will result in an error saying

The specified address already exists.Address…..”

Developers tacked this scenario by either manually registering the REST (clientacccesspolicy.xml) service at the end, or by using some custom WCF behaviour logic to delay its registration process.

Hidden Gem in AppFabric SDK 2.0 CTP – Easy Solution

As part of the AppFabric SDK V2.0 CTP samples (download details provided at the end), Microsoft released a sample application called “ClientAccessPolicyPublisher”, which allows you to upload your clientaccesspolicy.xml file to your root service bus namespace. Once the file is uploaded you can access it by simply navigating to it using the URL as shown below.

http://yournamespace.servicebus.windows.net/clientaccesspolicy.xml

This completely eliminates all the challenges we have discussed so far and it makes AppFabric service bus easily accessible via Silverlight applications.

The tool is simple to use, open command prompt and execute the exe Microsoft.ServiceBus.Samples.ClientAccessPolicyPublisher.exe

After providing AppFabric Service bus shared secret credentials, it will show the options as shown above. “P” will upload the default clientaccesspolicy.xml file (found under the same folder), which is pretty generic and allows the entire http* and https* connections. If you got specific restrictions you can specify your own.

The other options are self explanatory, which allows to see the existing policy file and delete it if required.

Important: The sample project points to the “appfabriclabs.com” and its hardcoded in code, so you need to open program.cs file and find and replace all “appfabriclabs.com” with “windows.net”.

Example:

var acsEndpoint = “https://” + serviceNamespace + “-sb.accesscontrol.windows.net/WRAPv0.9/”;

Download Details:

http://www.microsoft.com/download/en/details.aspx?id=17691

WindowsAzureAppFabricSDKSamples_V2.0-CS.zip

\AppFabric SDK V2.0 CTP\Samples\ServiceBus\Silverlight\ClientAccessPolicyPublisher

Special thanks to Mikael Hakansson for pointing me to this SDK sample. When I was there in Stockholm, Sweden for the BizTalk user group meeting and biztalk360.com promotion, I was discussing this topic with Mikael, since it’s in our road map to enable biztalk360 to use AppFabric service bus to support remote customer BizTalk server environment.

Nandri

Saravana

BizTalk Server 2010 Developer Training Kit

Found via Rahul Garg

This training kit contains a complete set of materials that will enable you to learn the core developer capabilities in BizTalk Server 2010. This kit includes lab manuals, PowerPoint presentations and videos, all designed to help you learn about BizTalk Server 2010. There is also an option below to download a Virtual Machine that is ready for you to use with the training kit.

http://www.microsoft.com/download/en/details.aspx?id=14865

The material looks really extensive, haven’t see one like this for any of the previous versions of the product.

After completing this course, students will be able to:

  • Work with schemas, maps, and pipelines, and create flat file schemas.
  • Configure a new FTP, HTTP and Windows SharePoint Services (WSS) adapter for BizTalk Server
  • Use BizTalk Orchestration Designer to create and test a simple orchestration.
  • Configure orchestration properties and variables, deploy an orchestration, and create and deploy a rule set and execute those rules from within an orchestration.
  • Define, deploy, and map a BAM observation model.
  • Use the deployment and management features in BizTalk Server
  • Build a simple Windows Communication Foundation (WCF) service and client and configure BizTalk Server to use a WCF Adapter.
  • Create a Microsoft .NET class library project that will contain a WCF Adapter.
  • Deploy artifacts needed for processing certain EDI documents and for turning XML messages into EDI.

Nandri!

Saravana

Artigo “Microsoft BizTalk Server aos olhos dos programadores” na Revista “Programar”

Artigo “Microsoft BizTalk Server aos olhos dos programadores” na Revista “Programar”

For the BizTalk Portuguese Community, I publish an article call “Microsoft BizTalk Server seen by the programmer’s eyes” on the Magazine “Programar”. J%u00e1 est%u00e1 dispon%u00edvel a 29%u00aa edi%u00e7%u00e3o da Revista PROGRAMAR, uma publica%u00e7%u00e3o digital gratuita com diversos artigos relacionados com desenvolvimento de software. Esta edi%u00e7%u00e3o cont%u00e9m um artigo da minha autoria sobre Microsoft BizTalk Server […]
Blog Post by: Sandro Pereira