How to generate a BizTalk schema for a SAP Web Service


I have several clients who own a SAP system, so I often develop integration flows that invoke BAPI exposed as Web Service. However, every time, I lose a lot of time in verifying the SAP configuration that allowed me to download the correct WSDL and generate a XSD schema. So, I decided to document every step, from the access to SAP to check the correct configuration up to the necessary actions on BizTalk side.


Configure the SAP logon settings


Start the SAP GUI program



Add new connection entry



Select “User Specified System”



There are two ways to access the SAP system, in this document I choose to connect directly to the application server.

Then, specify a connection Description, Application server name, Instance number and System ID.



Accept default settings and click Next



Select your language



At the end you have the configuration ready to use.



Access to SAP

To access SAP, use an existing connection or one configured previously specifying user and password



You should get an interface similar to that shown below



So specify “soamanager” in the command field



The SOA Management web interface appears. Click on “Web Service Configuration”



Search the BAPI you want to generate a WSDL



Select the BAPI and click on “Apply Selection”



You must be sure that the “WSDL format” section is set to “Standard”. Unlike the wizard of visual studio will not be able to generate correctly the XSD schema and the bindings file.



Click on “Open WSDL document for selected binding or service”



The Internet browser appears with the WSDL. Save the file to a folder.




Open the BizTalk Visual Studio project and Add a generated items.



Select “Consume WCF Service”



Select “Metadata Files (WSDL and XSD)”



In the Metadata Files form, add the WSDL file that you had previously saved and then click Next



Specify a Namespace and click on Import



That’s all. You have your SAP web services schema ready to use.


Handling fault messages from Microsoft Dynamics CRM SOAP interface


Typically, what you do to integrate BizTalk directly with the Microsoft Dynamics CRM SOAP API is to:


  • Generate CRM artifacts;
  • Replace the schemas generated with those found in the CRM SDK.


These two simple actions, allow you to implement integration flow with CRM. In case of errors in the interfaces, the CRM is able to generate fault messages that can be very useful for identifying and solving problems. To make sure that BizTalk intercepts properly these messages you need to follow two additional steps.


To generate CRM artifacts


Right click the BizTalk project and choose Add then Add Generated Items



Select “Consume WCF Service”



Select “Metadata Exchange (MEX) endpoint



Specify CRM WCF endpoint in the following form:





Specify a namespace



Following you can see the result



To replace schemas


As is known, the XSD generated by the wizard is not correct, then you need to replace them with those made available by the CRM SDK (Microsoft Dynamics CRM Software Development Kit (SDK) for CRM Online and CRM 2013 (on-premises)).


Remove the generated schemas



Right click the BizTalk project and choose Add then Existing Item



Browse the folder where you have unpacked the CRM SDK package, go into the “SDK\Schemas\CRMBizTalkIntegration” folder, select the schemas with the name that starts with “organizationservice” and click Add.



To catch CRM fault message

To make BizTalk intercepts fault messages generated by Dynamics CRM, you need to act on the configuration of the WCF service of CRM and the type of fault message defined on BizTalk side.


Locate the web.config WCF endpoint of Dynamics CRM.



Modify the section “system.serviceModel” inside the web.config.


Original Vesion


  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />


New version


  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />


From visual studio, open the orchestration generated by WCF service consuming wizard. From orchestration view, add a new multi-part message type



Optionally rename the object



Specify BTS.soap_envelope_1__1.Fault as message type. You can find this schema in the Microsoft.BizTalk.GlobalPropertySchemas assembly




Expand the port types, select the port generated by the WCF service consuming wizard and, for each operation, change the message type of the fault message, as shown below.



Troubleshooting SAP connectivity

I often develop integration flows that interact with SAP and sometimes I happen to have connectivity problems for many different reasons.

Every time, I start from scratch to make troubleshooting so I decided to write a memo that I hope will be useful to others too.


·          First of all, try to restart the receiving host. Sometimes occurs that some configuration change and the BizTalk host need to be restarted.


·          To isolate possible problems related to wrong schema, configure a receive location with passthru pipeline and create a send port that subscribes that port. Shutdown any other port or orchestration that subscribe the same receive port.


·          Unicode vs non-Unicode. Make sure that the SAP system is aligned with the versions of the DLLs of the SAP client you are using.

There are in fact a version of Unicode and non-Unicode one of the following DLLs:


·          icudt34.dll

·          icuin34.dll

·          icuuc34.dll

·          librfc32.dll

·          librfc32u.dll

·          librfc32u.lib

·          libsapu16vc80.dll

·          libsapu16vc90.dll

·          libsapucum.dll

·          libsapucum.lib

·          mfc71.dll

·          mfc71u.dll

·          msvcp71.dll

·          msvcr71.dll

·          saprfc32.lib


On SAP side, check the RFC destination configuration:




·          If the problem is not resolved, you must enable the detailed log on the WCF layer. For more details refer to the following site


Additional resources



BizTalk, RabbitMQ and JSON

In recent weeks, I happened to integrate RabbitMQ with BizTalk Server 2013. Great, I thought, there is a magnificent TechNet article that explains how to do it.

Too bad that I had to communicate using Json.

Anyway, Eventually I succeeded, but with some customization that I want to share.

The step to follow are four:


1.     Follow the article to configure all the components

2.     Customize RabbitMQ .Net Client

3.     Follow the article to Implement a custom pipeline component to receive e send Json messages

4.     Configure the send and receive ports


To customize RabbitMQ .Net Client


Open the solution and modify “rabbitmq-dotnet-client-3.2.1\projects\wcf\RabbitMQ.ServiceModel\src\serviceModel\RabbitMQInputChannel.cs” file.

In particular, find the “Receive” method and change the following highlighted line of code:




With the following:



var ms = new MemoryStream(msg.Body);

var bodyString = Encoding.UTF8.GetString(ms.ToArray());




bodyString = String.Concat(@”<s:Envelope xmlns:s=”””&#8221; xmlns:a=””””><s:Header><a:MessageID>urn:&#8221;, Guid.NewGuid().ToString(), “</a:MessageID></s:Header><s:Body>”, System.Web.HttpUtility.HtmlEncode(bodyString), “</s:Body></s:Envelope>”);




ms = new MemoryStream(Encoding.UTF8.GetBytes(bodyString));


Message result = m_encoder.ReadMessage(ms, (int)m_bindingElement.MaxReceivedMessageSize);



Then, find the “Open” method and change the following highlighted line of code:




With the following:



string[] uriParser = base.LocalAddress.Uri.PathAndQuery.Split(“/”.ToCharArray());


// Create a queue for messages destined to this service, bind it to the service URI routing key

string queue = m_model.QueueDeclare(uriParser[uriParser.Length – 1], true, false, false, null);



To configure the send port and receive location


Following screenshots of the configuration to be applied to the ports.


Send Port:








Receive Location:









Receive messages from DB2 AS/400

Well, in a technological age in which everyone is talking about Cloud, Windows Azure and BizTalk Services, it seems strange to talk about AS/400, but at least in Italy there are still many installations and I found few example of its use with BizTalk Server.

This article shows how to implement a simple receiving flow from AS/400 system to a target system. The example shown below reports the steps for installing the necessary components, to apply a basic configuration to a receiving port and to generate the message schema that you will receive from the AS/400.

Additional artifact such as target systems schema messages, maps or orchestration I take them for granted.


Components Setup

From the Microsoft Host Integration Server 2013 cd run setup.

On License Agreement screen select “Yes, I accept the Items…” and click Next.




On Usage Reporting Settings page make a selection and click Next.




On Component Installation screen select at least the components shown below and click Next.






Then click on Install.




Create Port and Packages

From BizTalk Server Administration console create a new port.




Specify the typical port properties








Select DB2 adapter and click Configure. Build the connection string as first step.




The wizard starts.




Select DB2/AS400 as data source platform.




Specify the AS/400 Network Name o IP address and a port number.




Specify at least the initial catalog, the package collection and the default schema.




Choose the international locale settings.




Then write the credentials.




To receive data from AS/400 is enough select the following advanced options.




On the review the connection properties page click Next.




On the Validation screen click on Packages to generate package on AS/400 library.




The connection string is composed. Now we have to specify the SQL Command.




Specify a SQL Command statement.




Note. To write and test SQL statement, typically I use Microsoft SQL Server Management console configuring a linked server to AS/400 system.


Now you have to specify “Document Root Element Name” and “Document Target Namespace” properties.




Generate Schemas

There are two option to generate AS/400 inbound schema:


·         Use thewizardfrom Visual Studio(this notalwaysgeneratesa schemethat works)

·         Activate the AS/400 receive port and write the output instance on a folder. Then using XML well formed generation schema to import the schema.


First option:

From Visual Studio start Add Generated Items wizard.




Choose Add Adapter Metadata.




Select DB2, then select the port created in the previous step.




Select the existing connection string.




Specify the same target namespace and root element name, chosen during port creation.




Then select the statement type (select statement in my case).




Specify the select sql script that the receive port will execute.




Now you have your AS/400 schema




Second option

From BizTalk Administration console, open the AS/400 receive location properties window an select (temporary) the PassThuReceive pipeline.




Then create a send port.




On the Filters tab, specify BTS.ReceivePortName equal to SampleQuery. This allow you to write messages coming from AS/400 in a folder.




Enable both receive location and send port. In the destination folder you will find an instance of message coming from AS/400 system.

Now, from Visual Studio you can use that instance to generate a schema.




Select Well-Formed XML and specify the generated file.




So you have your schema.




Ordered Delivery option just to serialize calls

Most of the integration scenarios includes database systems among the interlocutors.

If the database is not large, and contains a simple architecture of entities, develop interfaces is not so difficult.

Otherwise, if the architecture of entities and relationships is very complex and the occupation of space is hundreds of GB, it might be more difficult to write interfaces.

In this scenario, you can find thousands of tables, views, stored procedures with hundreds of lines of code and functions.

In these contexts, often we not even have visibility of the services that we going to call, and the risk of generating dead lock on tables is extremely high. This risk could increase, especially in the case of use of techniques such as message de-batching where BizTalk Server generates multiple thread with a perfect parallelism.

To overcome this, if you don’t have the opportunity to act within the stored procedures correcting the architecture of the lock, it is possible to enable the “ordered delivery” option on the WCF send port.

“When the port bound to the transport is marked for ordered delivery, then BizTalk Server enforces ordered delivery by ensuring that the transport does not get the next outbound message until the current one has been successfully sent. To achieve this, BizTalk Server passes each message to the transport’s adapter in a single batch and waits until the adapter has successfully deleted the message from the message box before delivering the next message, in another batch, to the adapter.”

Obvious that this is only an extreme measure and it is advisable to apply it only if is acceptable for the process, serializing the calls to the database, that even if they occupy a very small percentage of the whole process, still represent a bottleneck.

Polling Oracle Database Using Stored Procedures, Functions, or Packaged Procedures and Functions


This document shows the step to configure a polling operation using Oracle Function or Packaged Procedure and Functions.

Please refer to MSD article for additional detail (


Open Visual Studio, create a new BizTalk project and generate the polling schema using Consume Adapter Service wizard.


Click on “Configure”.


Specify a PollingId as Polling Unique Identifier.


Leave the following form with default settings.


Connect to the database, select “Service (inbound operation)” and choose the Oracle function.


Edit binding file in order to set the following properties:

1. Receive port name

2. Receive location name


3. If BizTalk host is Trusted you should set host trusted equal to true.


From BizTalk Administration import the generated binding file.


If needed, rename the receive port and enable routing for failed messages.


Rename the receive location.


Click on Configure and set the following properties:


In this example, we use the Oracle function CCM_ADT_PKG.CCM_COUNT, which require a string parameter.



From Visual Studio open the schema “schOracleA02CCM.PollingPackage.CCM_ADT_PKG.xsd” and find for the “action” element.


Copy the url “http://Microsoft.LobServices.OracleDB/2007/03/CCM/PollingPackage/CCM_ADT_PKG/CCM_BIZTALK_ADT_2” and set the PollingAction property.


From visual studio, generate a XML instance for the schema “schOracleA02CCM.Package.CCM_ADT_PKG.xsd”.


Modify XML content setting up the right parameters.

<ns0:CCM_BIZTALK_ADT_2 xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/CCM/Package/CCM_ADT_PKG">

Set Polling Interval to 30 seconds and user name and password.