다음을 통해 공유


BizTalk: Making BizTalk WCF Publishing Wizard Remember Previously Exposed Operations while Republishing The WCF Service

Introduction and Problem Scenario

Exposing BizTalk logic as WCF services either by exposing BizTalk schemas or Orchestration is a common practice.  It provides a way for the external world to communicate with BizTalk.  It is also common that a new operation may be added to the same service over time to incorporate a new requirement and expose it to the outer world. In such cases, the developer needs to run the WCF publishing wizard once again and then configure the WCF service for multiple operations. This can be tedious because, with each increasing operation that gets exposed, the developer needs to expose the previous operation again. If the number of operations is less then this process is okay, but if there are many operations then it becomes cumbersome and may invoke some error during the process. This article aims to discuss a way in which developer can force the WCF publishing wizard to remember the previous configuration.

PreRequisites 

This article expects that the reader has knowledge on how to publish BizTalk artifacts as WCF Service. If the reader is unaware, it is suggested to read following post.

Solution

The approach can be discussed best using an example. 

Exposing Create Operation

  • In a particular BizTalk app named BizTalkWCFPublishingWizardDemo there is a need to expose the Schema as WCF Service. 

  • Currently, the app caters to only one operation of Creating a customer. For this, the Schema shown below is exposed as WCF service.

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns="http://BizTalkWCFPublishingWizardDemo.FrontEndTypes" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalkWCFPublishingWizardDemo.FrontEndTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="CreateRequest">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Id" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="CreateResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Status" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    
  • Following screen shots high light the process used to expose the schema as WCF Service . The service is exposed using wcf-``basichttp and the receive location is created in BizTalk Application1.

    [

    ](resources/7635.Pic5.JPG)[

    ](resources/3348.Pic6.JPG)

  • Click on Next and then Create to publish the WCF service to the IIS.

  • The wizard creates a WCFServiceDescription.xml file inside the App_Data/Temp folder of the service. This XML file contains the information about the service like the operation name, the schemas used for the operation etc. The WcfServiceDescription.xml file for above service is as follows.

    <?xml version="1.0" encoding="utf-16"?>
    <WcfServiceDescription xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="BizTalkWcfDemoService" TargetNamespace="http://tempuri.org/" xmlns="http://schemas.microsoft.com/BizTalk/2006/01/Adapter/Wcf/Publishing">
      <LocationSettings Location="http://localhost/BizTalkWcfDemoService" Overwrite="false" AuthAnonymous="true" />
      <ApplicationSettings CreateReceiveLocations="true" ApplicationName="BizTalk Application 1" />
      <AdapterSettings AdapterName="WCF-BasicHttp" />
      <MetadataSettings EnableMetadata="true" MetadataOnly="false" ReceiveLocationName="" />
      <WcfServices>
        <WcfService Name="Demo">
          <WcfOperations>
            <WcfOperation Name="CreateCustomer" Flow="RequestResponse">
              <WcfMessages>
                <WcfMessage Name="Request" Direction="Input">
                  <WcfMessageType Category="XsdType" TypeName="BizTalkWCFPublishingWizardDemo.FrontEndTypes" AssemblyName="BizTalkWCFPublishingWizardDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" AssemblyLocation="C:\Users\mandar\Documents\Visual Studio 2012\Projects\BizTalkWCFPublishingWizardDemo\BizTalkWCFPublishingWizardDemo\bin\Debug\BizTalkWCFPublishingWizardDemo.dll" TargetNamespace="http://BizTalkWCFPublishingWizardDemo.FrontEndTypes" RootName="CreateRequest" IsAnyType="false" IsEnvelope="false" />
                </WcfMessage>
                <WcfMessage Name="Response" Direction="Output">
                  <WcfMessageType Category="XsdType" TypeName="BizTalkWCFPublishingWizardDemo.FrontEndTypes" AssemblyName="BizTalkWCFPublishingWizardDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" AssemblyLocation="C:\Users\mandar\Documents\Visual Studio 2012\Projects\BizTalkWCFPublishingWizardDemo\BizTalkWCFPublishingWizardDemo\bin\Debug\BizTalkWCFPublishingWizardDemo.dll" TargetNamespace="http://BizTalkWCFPublishingWizardDemo.FrontEndTypes" RootName="CreateResponse" IsAnyType="false" IsEnvelope="false" />
                </WcfMessage>
              </WcfMessages>
            </WcfOperation>
          </WcfOperations>
        </WcfService>
      </WcfServices>
    </WcfServiceDescription>
    

Adding New Operation

  • As per new requirement, another operation Update needs to be exposed out from the same WCF Service to the outer world. Now the modified XSD for app looks like following.

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns="http://BizTalkWCFPublishingWizardDemo.FrontEndTypes" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalkWCFPublishingWizardDemo.FrontEndTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="CreateRequest">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Id" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="CreateResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Status" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="UpdateRequest">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Id" type="xs:string" />
            <xs:element name="value" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="UpdateResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Status" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    
  • Now the developer again wants to expose the new Update operation in the same wcf service. When the developer launches the BizTalk WCF Publishing Wizard from Visual Studio, it calls the BtsWcfServicePublishingWizard.exe which is present in the BizTalk installation folder. 

  • In order to make the Wizard remember the previously exposed operation, the BtsWcfServicePublishingWizard.exe should be invoked by providing WcfServiceDescription.xml file as a parameter.  Create a batch file with name RememberWCFDescription.bat and place it inside the IIS application folder of the service .

    @echo off
    Start BtsWcfServicePublishingWizard.exe -WcfServiceDescription= <PhysicalPath To the Application in IIS>\App_Data\Temp\WcfServiceDescription.xml
    
  • Once this run, the WCF publishing Wizard is launched as shown below.


    As the Receive Location is created already, it is not necesary to specify the BizTalk Application name here.Next the publishing type needs to be set, if the orchestration or schema needs to be published.

    [

    ](resources/5556.Pic2.JPG)When clicked on Next, the Window where the new operation can be added will pop up. As clear from follwoing screen shot, the wizard now remembers the operation that was exposed previously.

  • Other operation of Update can be exposed as done previously with the Create Operation.

Conclusion

Using the WcfServiceDescription.xml file with the BizTalk WCF Publishing Wizard allows the Wizard to remember previously exposed operations and saves the time of the developer when new operations are to be exposed frequently. Only things that need to be specified while exposing the new operation in the same service is the type of the service ( Biztalk Orchestration or Schema published as WCF Service ) and the target namespace for the service of one is specified in the first place.


See Also

A place to find BizTalk Related articles on Technet wiki is  BizTalk Server Resources on the TechNet Wiki