BizTalk Integration with Windows Azure AppFabric Service Bus : Publishing Service Bus messages to BizTalk Server (part 2 ) - Building the BizTalk solution components
2. Building the BizTalk solution components
We need to create a single message schema to start with, and then configure our BizTalk and service endpoints.
Defining message schemas
Our first step is to build the schema definition describing the request for access and then create a web service that accepts a message of that type.
Open the Chapter6.BuildingAccessManagement.sln solution and create a new BizTalk project named Chapter6.BuildingAccessManagement.BizTalk.
Configure the project with a strong name key and set it to deploy to a BizTalk application named Chapter 6.
Add a new schema named AccessRequestEvent_XML.xsd to the BizTalk project.
Construct the schema with the fields outlined below and each data type set to "string".&;
Next, define a Promoted Field so that we can later route on the CompanyId field. Add a Promoted Property Schema named BuildingAccess_Prop.xsd to the project.
Add a field named CompanyID to the property schema.
Map the CompanyId field in the AccessRequestEvent_XML.xsd to the CompanyID field in the property schema.
Build and deploy the BizTalk application.
Exposing a service endpoint
Next up, we take our schema and use it to expose an on-premises service endpoint. This schema is used to construct two distinct services to expose the "Request Access" and "Revoke Access" operations. Why do we have two services instead of a single service with two operations? We want the option to add fine-grained authorization control to these operations and cannot do so easily if we only have a single receive location, which is what the BizTalk WCF Service Publishing Wizard produces for each individual service solution.
In Visual Studio 2010, go to the Tools menu and launch the BizTalk WCF Service Publishing Wizard to build the first service endpoint that we need.
Choose the WCF-CustomIsolated adapter and select the Enable on-premise metadata exchange and Create BizTalk receive locations in the following application options.
Next, choose to publish schemas as a web service. This option lets us manually build out a service definition as opposed to using an orchestration to generate the service's name, operation name, and message types.
Skip the option to build a Service Bus endpoint on the following wizard pane. At this stage, we are only exposing the service to local consumers, per our first use case. In a future step, when we simulate the elimination of the VPN between the two companies, we will "cloud enable" our endpoint.
Now, we have the option to manually shape our service definition for the RequestAccessService.
After defining our service, set the target namespace to http://Chapter6/BuildingAccessManagement.
Deploy the service at this address: http://localhost/RequestAccessService.
Complete the wizard and verify a successful deployment by confirming that the new service exists in IIS and is associated with an Application Pool that runs under an account with permission to publish to the BizTalk MessageBox database.
If we dig a bit into our wizard-generated service, we see a few interesting things. First, when you open the svc file you see that CustomWebServiceHostFactory was used instead of the standard WCF ServiceHost. This leads to the second interesting point. Look at the web.config file and notice a very sparse system.serviceModel section. There is no specific endpoint definition for the web service. This is because the CustomWebServiceHostFactory mentioned earlier pulls in the receive location configuration details to configure the service. The endpoint that you will find in the web.config file's system.ServiceModel is a definition of our Metadata Exchange (MEX) endpoint.
Switch to the BizTalk Server Administration Console and open the Chapter 6 application.
Find the wizard-generated receive location, open it, and set the binding to BasicHttpBinding.
Start the receive location and browse to the service address and notice a working metadata link.
With the "Request Access" service complete, we once again walk through the BizTalk WCF Service Publishing Wizard to build a "Revoke Access" service produced.
Select the same adapter (WCF-CustomIsolated) as the last walkthrough of the wizard and once again choose to build a service from schemas.
Set the target namespace of the service to http://Chapter6/BuildingAccessManagement
Set the deployment address of this service to http://localhost/RevokeAccessService
Complete the wizard and confirm success by finding the service in IIS, setting a valid Application Pool, and setting the binding on the generated receive location to BasicHttpBinding.
With our inbound service channels defined, we now need a send port that subscribes to our published content. Define a new one-way, static send port that emits our messages to disk. The subscription for this send port is based on the message type property.
We now have the base components for the first part of our solution. Next, we will define the Azure AppFabric Access Control (AC) service settings to overlay granular authorization to our internal service endpoints.