biztalk generate xsd schema

BizTalk Server Best practices, Tips, and Tricks: #7 Automatically Generate XSD Schemas

Welcome once again to another BizTalk Server Best practices, Tips, and Tricks blog post! In my previous blog post, I discussed some essential tips and tricks for BizTalk Server administrators:

And for BizTalk Server Developers:

Today I’m going to speak about another critical Best practice, Tips and Tricks for BizTalk Server developers: Automatically Generate XSD Schemas

Automatically Generate XSD Schemas

#7 Automatically Generate XSD Schemas

There are several ways we can create an XSD Schema or XML Schema in BizTalk Server. Of course, you can always manually create the XSD schemas from scratch, but normally the Schema generation should be a simple, easy and fast operation. These are our options for creating XSD schemas:

Manually create an XSD schema from scratch

This is the option for you to create, especially internal or our own schemas from our BizTalk Server applications.

To create a new schema, you need to:

  • In Solution Explorer, select the BizTalk project to which you want to add a schema.
  • On the Project menu, click Add New Item.
  • In the Add New Item – <BizTalk ProjectName> dialog box, in the Templates section, click Schema.
  • In the Name box, type a name for the schema, and then click Add.

create an XSD schema

  • Then in the schema tree view, you need to manually create and define the structure of your message.

Automatically create the XSD schema from an XDR Schema instance

XDR is a discontinued schema language for specifying and validating XML documents. BizTalk has a simple way option for you to migrate them to  XSD Schemas.

To generate an XSD schema from an XDR schema, you need to:

  • In Solution Explorer, right-click the relevant BizTalk project, point to Add, and then click Add Generated Items.
  • In the Add Generated Item – <BizTalk ProjectName> dialog box, in the Templates section, click Generate Schemas and then click Add.
  • In the Generate Schemas dialog box, in the Document type list, select XDR Schema.

create XSD schema from a DTD instance

  • Click Browse, locate the XDR schema file you want to migrate and then click OK.

A new schema is generated from the specified XDR schema file, using the same name as that file with the .xsd extension, and then opened in BizTalk Editor.

Automatically create the XSD schema from a DTD instance

For those who don’t know what DTD is, a DTD is a Document Type Definition that defines the structure and the legal elements and attributes of an XML document… So basically, it is the equivalent of what BizTalk Server uses to define how an XML document can be structured: XSD Schema. Nevertheless, there are many differences between DTD (Document Type Definition) and XSD (XML Schema Definition). In short, DTD provides less control on XML structure whereas XSD (XML schema) provides more control.

Some of you may wonder, who cares? No one uses DTD anymore, so why bother? Yes, indeed, DTD is not used very regularly nowadays, and, probably, you will never use it… unless… for example, you are working with RosettaNet or in the future, you will need to work with RosettaNet. Why? Because most of the RosettaNet Standards – PIP messages – are defined in the format of DTD format!

To accomplish this, we need to:

  • In Solution Explorer, right-click a BizTalk project, point to Add, and then click Add Generated Items…
  • In the Add Generated Items – <BizTalk ProjectName> dialog box, in the Templates section, click Generate Schemas, and then click Add
  • In the Generate Schemas dialog box, in the Document type drop-down list, select DTD

create the XSD schema from XML

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

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.

Quick, simple, and practical.

Automatically create the XSD schema from a well-formed XML instance

If you already have a valid XML instance or message with you, why spend too much time trying to manually create an XSD schema that represents that message? Why not automatically generate one based on that 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…
  • In the Add Generated Items – <BizTalk ProjectName> dialog box, in the Templates section, click Generate Schemas, and then click Add
  • In the Generate Schemas dialog box, in the Document type drop-down list, select Well-Formed XML

Import XSD Schemas

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

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

Import XSD Schemas from a WCF Service or Web Service

The BizTalk Adapter Framework provides a way to add adapter schemas and BizTalk types to BizTalk projects. The BizTalk WCF Service Consuming Wizard enables you to add WCF send adapters to a BizTalk project.

To add the schemas and types for WCF send adapters to your project

  • In your Microsoft Visual Studio BizTalk project, in Solution Explorer, right-click your project, click Add, and then click Add Generated Items.
  • In the Add Generated Items – <Project name> dialog box, in the Templates section, select Consume WCF Service, and then click Add.
  • On the Welcome to the BizTalk WCF Service Consuming Wizard page, click Next.
  • On the Metadata source page, select the metadata source to import, and then click Next.
  • If you select the Metadata Exchange (MEX) endpoint option on the Metadata source page, the Metadata Endpoint page appears. On the Metadata Endpoint page, specify the URL to the running service that provides metadata for download through WS-Metadata Exchange or Http-Get. To get the metadata document from the URL, click Get. If the running service requires a user credential with the basic authentication scheme, click Edit to open the BizTalk WCF Service Consuming Wizard dialog box in which you can supply the user name and password to use when accessing and running the service.

generate XSD schemas from LOB

The BizTalk WCF Service Consuming Wizard creates in your BizTalk project the BizTalk schemas and types necessary to consume WCF services. 

Automatically generated XSD schemas from LOB systems (from the adapters)

And the last option is to generate the XSD schemas directly from our LOB systems like Oracle, SQL Server or SAP.

To accomplish that we need to:

  • In your Microsoft Visual Studio BizTalk project, in Solution Explorer, right-click your project, click Add, and then click Add Generated Items.
  • In the Add Generated Items – <Project name> dialog box, in the Templates section, select Consume Adapter Service, and then click Add.
  • The Consume Adapter Service Add-in will open and then:
    • From the Select a binding drop-down list, select your LOB system like, for example, sqlBinding, and then click Configure.

    • In the Configure Adapter dialog box, click the Security tab, and from the Client credential type drop-down list.

    • Click the URI Properties tab, and then specify values for the connection parameters.
    • Click Connect. After the connection is established, the connection status is shown as Connected.

biztalk generate xsd schema

Of course, you need to select the actions you want, like calling a stored procedure or performing a Select of a table, and click OK for the wizard to generate and add that XSD Schemas to your BizTalk Server Visual Studio project.

Stay tuned for the following BizTalk Server Best practices, Tips, and Tricks.