CODit

Hosting WCF HTTP receive location inside BizTalk, without using IIS.

by sam 11. August 2010 14:12

Recently I was in Redmond for the BizTalk VTS Summit, with a bunch of colleague BizTalk experts from all over the world.  During one of the discussions we had, a question came up about the fact that it seemed that to host HTTP endpoints, it is required to have IIS as the real host configured.

After my suggestion that is was perfectly possible to bypass IIS in this process, it looked that quite a number of attendees didn’t know about this.  And that’s the reason why I decided to add it to our blog…

WCF-Custom vs WCF-CustomIsolated

First of all, I think it is a best practice to avoid using the non-WCF-custom adapters (like WCF-WSHttp, etc).  I always suggest colleagues and customers to use the WCF-Custom or WCF-CustomIsolated adapter, since they are the only adapters that provide the maximum capabilities of WCF in BizTalk.  The other WCF-* adapters only provide a subset of the various binding and behavior settings, specific for their binding, which results in an adapter change, when a more advanced setting is needed one day.

The WCF-Custom adapter, is the adapter that is used to host WCF endpoints inside BizTalk.  The WCF-Isolated adapter is hosted in a BizTalk Isolated Host, which is typically IIS.

The BizTalk WCF Service Publishing wizard

To expose an orchestration or a schema as a WCF service in BizTalk, the BizTalk WCF Service Publishing wizard is the typical way to use.  In this wizard, the orchestration or schema needs to be selected and a choice between three adapters is possible: WCF-BasicHttp, WCF-WSHttp, WCF-CustomIsolated. 

The last step of the wizard is used to create a web directory in IIS, where the BizTalk svc file will be created that hosts the custom WCF Service Host that will link through to the BizTalk Receive location. 

WCF Service type WCF Service Location

Unfortunately, the WCF Publishing wizard does not allow to select the ‘In-Process’ adapters.  All of the three adapters/bindings are only available through an isolated host and required IIS.

Hosting the endpoint in the BizTalk process

To host the endpoint inside the BizTalk process, we need to manually create the WCF receive location.  To do so, we just need to select the WCF-Custom adapter and use the desired binding: BasicHttpBinding or WsHttpBinding. 

The following steps need to be used for this:

  1. Create a new receive location with the desired name
  2. Select the WCF-Custom adapter and open the properties for this adapter
  3. Specify an address for the endpoint (picture 1) Take into account that when IIS is already running on the machine, you might need to specify a different available port.
  4. Select your binding (or use the customBinding for full flexibility) in the Binding tab page. (picture 2) and set all desired binding properties to their correct setting.
  5. In the Messages tab page, you can also specify that failed request messages need to be suspended and that exceptions should be returned to the consumer. (picture 3)

wcf1 wcf2 wcf3

Metadata publication

One downside of this way of work is the metadata publishing.  If you would query the exposed endpoint for the WSDL, you would get to see the WSDL of the generic BizTalk WCF Service Host with the 5 operations.

Therefore, it is needed to publish the metadata endpoint to IIS and provide that endpoint to the consumers of your in-process service.  But this way of work, is similar to the other protocols (like netMsmq, netTcp…)

Advantages

  • Consistent approach for all binding types, independent of protocol.
  • No extra configuration / deployment needed (specific IIS security on IIS application pools, etc)
  • Performance (no extra hop)

Sam Vanhoutte, CODit

Tags: , ,

BizTalk | WCF

Permalink | Comments (4)

WCF-Adapter - Setting a trace

by gcolpaert 21. April 2010 15:34

In this post I will talk about setting up a trace for the WCF-Adapter. This post should be a good addition to some previous posts I made about the WCF-Adapter.

Communicating with SAP through WCF : Send and Receive Ports

Communicating with SAP through WCF : Generate SAP schemas

1.  Tracing within the Adapter

 

Add the following to the configuration section of your BizTalk configuration file, BTSNTvc.exe.config which is present under <system drive>:\Program Files\Microsoft BizTalk Server 2006:

 

<system.diagnostics>

    <sources>

      <source name="Microsoft.ServiceModel.Channels" switchValue="Warning">

        <listeners>

          <add name="eventlog" />

        </listeners>

      </source>

      <source name="Microsoft.Adapters.SAP" switchValue="Warning">

        <listeners>

          <add name="eventlog" />

        </listeners>

      </source>

    </sources>

    <sharedListeners>

      <add name="eventlog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/>

      </sharedListeners>

    <trace autoflush="false" />

  </system.diagnostics>

This will enable Warning level tracing (Errors + Warnings).  Replace APPLICATION_NAME with the name of your application as you want it to appear in the event viewer. Now you can see the errors and warnings - even the ones that were thrown to SAP.

If not possible to write to event log or if too bulky, then alternatively, you can put the following instead of the listeners “event log” if you want to log to a file. You will then need the tracing viewer (see below):

 

<add name="xml" type="System.Diagnostics.XmlWriterTraceListener"

   traceOutputOptions="LogicalOperationStack"

          initializeData="C:\log\WCF\AdapterTrace.svclog" />

ATTENTION: Trace files can become huge. Remember to stop tracing once issues have been solved.

2.  Tracing the Adapter and the LOB Application

To diagnose issues that you suspect are related to the LOB application, you must enable tracing for communication between the adapter and the LOB application. Adapters also depend on LOB tracing (client/server side) to access this information. The SAP adapter enables adapter clients to turn on tracing within the SAP system by specifying the "RfcSdkTrace" parameter in the connection URI. You must specify this parameter to enable the RFC SDK to trace information flow within the SAP system. For more information about the connection URI, see The SAP System Connection URI.

This parameter is specified in the SAP binding URI of the BizTalk WCF adapter:

 

Additionally, you can also create an RFC_TRACE environment variable that sets the level of tracing for the RFC SDK. RFC_TRACE is an environment variable defined by SAP and is used by the RFC SDK. If this variable is not defined or is set to 0, the RFC SDK tracing level is bare minimum. If the variable is set to 1 or 2, the tracing level is more detailed.

 

RFC_TRACE = 2
RFC_TRACE_DIR =
C:\log\LOB

Note: Irrespective of whether the RFC_TRACE environment variable is set, the RFC SDK tracing is enabled only if setting the "RfcSdkTrace" parameter to true in the connection URI (see in STEP 2). The value of this environment variable solely governs the level of RFC SDK tracing. If RfcSdkTrace is set to true, the message traces between the adapter and the SAP system are copied to the “system32” folder on your computer. To save the RFC SDK traces to some other location, you can set the RFC_TRACE_DIR environment variable. For more information about these environment variables refer to the SAP documentation.

3.  Viewing the Traces

You can use the Windows Communication Foundation (WCF) Service Trace Viewer tool to view the traces. For more information about the tool, see "Using Service Trace Viewer for Viewing Correlated Traces and Troubles" at http://go.microsoft.com/fwlink/?LinkId=91243 .

Enjoy!

Glenn Colpaert 

Tags: , , ,

BizTalk | WCF

Permalink | Comments (10)

Communication with SAP through WCF custom adapter – Send and Receive Ports

by gcolpaert 2. March 2010 15:40

In order to successfully setup communication with SAP. You have following configurations.
In terms of the SAP part you need to have following things on SAP side:

·         A SAP user with suitable access

·         A RFC connection (This will specify the ‘listening’ program running on BizTalk. (SAP transaction SM59)

·         A tRFC port which uses the RFC connection defined above. (SAP transaction WE21)

There is also some setup in terms of messages. Assignment of messages to receiving/sending partner…
But this would be down to the SAP team for doing this sort of implementation.

The most important thing from BizTalk point of view is the configuration of the Send and Receive ports.
There for you need to first generate the correct SAP schemas.  (See blog post: “Communication with SAP through WCF custom adapter – Generate SAP schemas”).

Note: When generating the SAP schemas, BizTalk will provide you with the correct bindings to setup the Send/Receive Ports.
On the other side, it’s better to cross-check that configuration to be sure that you have the correct setup.

Send Ports

Your URI should look like this:

sap://CLIENT=[SAPClientID];LANG=[LANG];@a/[ServerName]/[SystemID]?RfcSdkTrace=False&AbapDebug=False
ex: sap://CLIENT=235;LANG=EN;@a/10.80.32.3/00?RfcSdkTrace=False&AbapDebug=False

In the SOAP Action header you should specify the action, this action you can find in the configuration of your generated SAP schema. 

Double check the configuration of the URI and do not forget to add your credentials to avoid logon problems. 

Receive Ports

Your URI should look like this:

sap://CLIENT=[SAPClientID];LANG=[LANG];@a/[ServerName]/[SystemID]?ListenerGwHost=[ListenerGWHost]&amp;ListenerGwServ=[ListenerGWService]&amp;ListenerProgramId=[ListenerProgramID]
ex: sap://CLIENT=235;LANG=EN;@a/10.80.32.3/00?ListenerGwHost=10.80.32.3&amp;ListenerGwServ=SAPGW00&amp;ListenerProgramId=BIZTALK_CODIT

The SAP team has to provide you with the correct variables. Again, do not forget to add your credentials to avoid logon problems.
If you still have issues with enlisting your Receive Locations you should paste following entries in c:\windows\system32\drivers\etc\services.
 Services.txt (3.71 kb)

Enjoy !

Glenn Colpaert 

Tags: , ,

BizTalk | WCF

Permalink | Comments (14)

Communication with SAP through WCF custom adapter – Generate SAP schemas

by gcolpaert 2. March 2010 15:29

In order to send and receive messages from SAP you need to have the correct schemas generated from SAP.
To successfully generate those schemas you need following prerequisites installed.

·         BizTalk - SAP LOB Adapter SDK SP2

·         BizTalk – Adapter Pack 2.0

·         BizTalk – SAP client libraries 

Create a new project in Visual Studio. Click “Add Generated Items”. 

Select “Consume Adapter Service”.

  

Select the “sapBinding” and press “Configure”.
Configure the URI properties (application server host, the gateway host, the gateway service, the system number, the client, programid) and credentials provided.

 

  

When the configuration is finished press the “Connect button”.
In the following sceen you can Select Client (Outbound operations) or Server (Inbound Operations), then you can select the IDOC you want.
Be sure to select the correct version of the IDOC. Select the Send or Receive operation and click “OK” to generate the schema.

  

 Generating a schema will provide you with the correct schemas and a binding file that you can use to setup the receive or send port.
(See blog post: “Communication with SAP through WCF custom adapter – Send and Receive Ports”)

  

 

Enjoy !

Glenn Colpaert

Tags: , , ,

BizTalk | WCF

Permalink | Comments (13)