BizTalk Server Tips and Tricks: Automatically Generate Schemas from a Well-Formed XML instance

BizTalk Server Tips and Tricks: Automatically Generate Schemas from a Well-Formed XML instance

Welcome back to my blog post series “BizTalk Server Tips and Tricks” for developers, administrators or business users.

There are several ways we can create an XML Schema in BizTalk Server:

  • Manually from scratch
  • From XDR Schema instance
  • From a DTD instance
  • From a well-formed XML instance
  • Import them from a WCF Service or Web Service
  • Automatically generated them from LOB systems (from the adapters)

Today, we will be talking about automatically generating XML Schemas from a well-formed XML instance. To accomplish this we need to perform the following steps:

  • In Solution Explorer, right-click a BizTalk project, point to Add, and then click Add Generated Items…

BizTalk Server: Generate Schemas from a Well-Formed XML

  • In the Add Generated Items – <BizTalk ProjectName> dialog box, in the Templates section, click Generate Schemas, and then click Add

BizTalk Server: Generate Schemas from a Well-Formed XML

  • In the Generate Schemas dialog box, in the Document type drop-down list, select Well-Formed XML

BizTalk Server: Generate Schemas from a Well-Formed XML

  • One of the problems, especially in brand new installations, is that sometimes this feature was not installed, and you will see Well-Formed XML (Not Loaded) in the drop-down list. To install and use this feature you need to:
    • Start a Windows Explorer and navigate to the “SDKUtilitiesSchema Generator” folder present in the BizTalk Server installation folder;
      • Normally it will be “C:Program Files (x86)Microsoft BizTalk Server <version>SDKUtilitiesSchema Generator”
    • Execute the InstallWFX.vbs script by double-clicking. This will install the “Microsoft.BizTalk.WFXToXSDGenerator.dll” DLL on the correct place
      • That basically means, it will copy this DLL to the “Developer ToolsSchema Editor Extensions” folder present in the BizTalk Server installation folder
    • Or manually copy “Microsoft.BizTalk.WFXToXSDGenerator.dll” DLL to the “Developer ToolsSchema Editor Extensions” folder, present in the BizTalk Server installation folder
      • Normally, it will be “C:Program Files (x86)Microsoft BizTalk Server <version>Developer ToolsSchema Editor Extensions
  • Close the Generate Schemas dialog box and do the previous steps again, and now you will be able to see that you already can use the option Well-Formed XML in the drop-down list.

BizTalk Server: Generate Schemas from a Well-Formed XML

  • In the Generate Schemas dialog box, click Browse, locate the file you want to import, click Open and then click OK

BizTalk Server: Generate Schemas from a Well-Formed XML

  • A new schema, or sometimes at least two schemas are generated from the specified file, using the same name as that file with the .xsd extension, and opened in BizTalk Editor

TIP: Before you generate the schemas, rename the XML instance file that you will be using to the proper name you want to give to the Schemas, this will save you time because the Generator Wizard will:

  • Give the same name of the specified file with the .xsd extension
  • Or will add a sequence to the same name of the specified file with the .xsd extension

In the end, as a best practice, you should rectify or rename the schemas generated to something with context and that will be easy to identify:

If you want it to be perfect, then for each schema, you should change not only the name of the file, but also the Type Name property of each schema.

BizTalk Server: Generate Schemas from a Well-Formed XML

Initially, this value was set as “myfilename_0”.

The problem of renaming the filename and/or the Type Name property is that once you try to compile it will give you errors because some schemas will be referring files that no longer exist (were renamed):

To solve this, we need to:

  • Open the Schema and select the Schema node at the top of the schema tree view
  • In the Properties window, in the Advanced category, in the value portion of the Imports property, click the ellipsis () button
  • In the Imports dialog box, in the Import Schema list, delete the XSD Import line, import the correct one and then click OK

BizTalk Server: Generate Schemas from a Well-Formed XML

  • Alternatively, open the schema file in Notepad (Notepad ++ or other text editors) and rectify the path and filename

Quick, simple and practical!

Stay tuned for new tips and tricks!

Author: Sandro Pereira

Sandro Pereira is an Azure MVP and works as an Integration consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. View all posts by Sandro Pereira

BizTalk Server Tips and Tricks: Another way to set unlimited occurrences on schema elements

BizTalk Server Tips and Tricks: Another way to set unlimited occurrences on schema elements

Welcome back to my blog post series “BizTalk Server Tips and Tricks” for developers, administrators or business users. Not all tips and tricks are sophisticated or quite robust and ingenious, some of them are quite simple. Some of them are in front of us all the time without us noticing, this is one of these cases.

Today there is a lot more information than in the past, but normally when we start BizTalk Server tutorials about schemas, they tend to say that if you want to specify how many times a record or an element will occur, you should configure the below values:

  • The Max Occurs property to specify the maximum occurrences of this node (record or element). The default value is ‘1’ and cannot be less than the Min Occurs property
  • The Min Occurs property to specify the minimum occurrences of this node. The default value is ‘1’ and cannot be greater than the Max Occurs property

What this type of tutorial also tells you, is that if you want to specify that a specific node can appear an unlimited number of times, at the Max Occurs property, you should type the value: “unbounded

Another way to set unlimited occurrences on schema elements

So, we tend to manually write the word “unbounded”, each time we want to set a node to appear an unlimited number of times… I think, I can write this word better than my personal name, so many are the times I’ve written it over the years. But to be honest, this can be a little time consuming. Especially if we type it wrongly, newbies need to remember this word – there are other words with the same meaning as unlimited – and sometimes is just a little boring.

Well, guess what, if you are at this point of the post wondering what is the alternative, in the future you should spend a little time reading the description of property inside Visual Studio; the alternative has been there in front of you all the time:

  • Maximum Occurrences of this node. Its value should always be greater than or equal to minOccurs of this node. Use ‘unbounded’ or ‘*’ (asterisk) to indicate unlimited occurrences. The default value is ‘1’.

Another way to set unlimited occurrences on schema elements: max occurs description

Which means that if we type * (asterisk), this will be automatically translated to “unbounded”.

Another way to set unlimited occurrences on schema elements: asterisk

Quick, simple and practical

Stay tuned for new tips and tricks!

Author: Sandro Pereira

Sandro Pereira is an Azure MVP and works as an Integration consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. View all posts by Sandro Pereira

BizTalk Server Tips and Tricks: Configure Visual Studio to run with elevated permissions (as administrator)

BizTalk Server Tips and Tricks: Configure Visual Studio to run with elevated permissions (as administrator)

With all these new security features present on the latest Microsoft operating systems, don’t get me wrong they are good, sometimes our life as BizTalk Developers seems like it’s reversing and becoming a nightmare, especially if you are a consultant working with multiple different clients, environments, and projects.

Most of the times I start developing a new project at a new client, the first time I try to deploy a solution I get an “Error 87 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))…” error message.

Visual Studio: BizTalk Server deployment fails

There are several possible causes for you to get such Access Denied errors when deploying BizTalk solutions directly from Visual Studio. Most common is that you don’t have the right BizTalk privileges to deploy artifacts, or in other words, you are not a local Administrator.

But most of the time is simpler than that and indeed is related with these additional securities setting present in recent Windows Server versions. For you to be able to successfully deploy a BizTalk Server solution directly from Visual Studio, you must run Visual Studio as an Administrator, or with elevated permissions, because BizTalk assemblies need to be deployed into the GAC. What normally happens, is that if you have User Account Control (UAC) activated, or sometimes even deactivated, there are some additional securities setting present in recent Windows Server versions that, by default, doesn’t run Visual Studio with elevated permissions.

The quick solution is for you to run Visual Studio as an Administrator by simply run below step:

  • Right-click under Visual Studio and choose “Run as administrator” option.

Visual Studio: Run as Administrator

The problem with this approach is that you need to remember yourself to do it every time you want to run Visual Studio, otherwise the next time you try to deploy the solution it will fail again with the same error.

How to properly address this problem?

Actually, this problem can be simply addressed by:

  • Access the devenv.exe file on the file system, which is by default installed in: “C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDE”
  • Right-click devenv.exe and select “Troubleshoot compatibility”

Visual Studio: troubleshoot compatibility

  • On the “Select troubleshooting option” page, select “Troubleshoot compatibility” option

Visual Studio: troubleshoot option

  • On the “What problems do you notice?” page, select the “The program requires additional permissions” option and then click “Next”

Visual Studio: requires additional permissions

  • On the “Test compatibility settings for the program” page, click “Test the program…”, wait for the program to launch and then click “Next”
  • Select “Yes, save these settings for this program”

Visual Studio: save settings

  • Click “Close”

You will never face this problem again… at least at that client.

Enjoy and Stay tuned for new BizTalk Server Tips and Tricks!

Author: Sandro Pereira

Sandro Pereira is an Azure MVP and works as an Integration consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. View all posts by Sandro Pereira