Wednesday, December 19, 2007

Call SubmitDirect Adapter from Orchestration

If we want call SubmitDirect directly from Orchestration, we will get this error:

"The Messaging Engine failed to register the adapter for "Submit" for the
receive location "submit://submitrequest". Please verify that the receive
location is valid, and that the isolated adapter runs under an account that
has access to the BizTalk databases."


This error is because SubmitDirect adapter needs to run in an Isolated process, because is an Isolated adapter.

My solution is convert this adapter in an In-Process adapter. This is simple, we need to do 2 changes in the SubmitDirect solution:

1) Implement IBTTTransportControl at BizTalkMessaging class (in MessagingAPIs.cs at TransportProxyUtils project), for example:

public void Initialize(IBTTransportProxy transportProxy)
{
_tp = transportProxy;
}

public void Terminate()
{
}

2) Change RegisterAdapter.cs in TransportProxyUtilsReg project:

Change this line "rkBizTalk.SetValue("Constraints", 0x00000081);" with "rkBizTalk.SetValue("Constraints", 0x00000089);"

First change is to implement all interfaces that need an In-Process adapter (see BizTalk documentation "Interfaces for an In-Process Receive Adapter").

Second change is to indicate that our adapter is hosted in-process (see BizTalk documentation "Registering an Adapter -> Constraints -> eProtocolReceiveIsCreatable flag).

With this changes, we build the solution and then, we register our custom SubmitDirect adapter and voilà, we can call SubmitDirect adapter from a Orchestration without errors, because our adapter will run within BizTalk process.

Monday, December 17, 2007

XPath inside BizTalk

XPath is a powerfull feature in BizTalk solutions, but is little complicated when we have a lot of namespaces and elements.

If we develope a solution wich uses this feature, it can be very frustrating, because it's a thorny issue.

There is a good tool that help us to test our xpath expressions, XPathmania.

This tool is a plug-in for Visual Studio 2005 and allows us to do queries against a XML document. After install it, we open this tool in View -> Other Windows -> Xpathmania menu:


If we open a XML document, we can test our xpath queries:


If xpath query is correct, Xpathmania will set the backcolor of selected nodes to green. If it is any sintax error in our query, Xpathmania will tell us the error:

Sunday, December 09, 2007

"No XOP Parts"

Due to a bug in Axis2 1.3, when we call a web service from a .NET application using WSE 3.0 and MTOM, we receive this error: "WSE1608: No XOP parts were located in the stream for the specified content-id: ...".

The problem is that in Axis2 response we receive something like this:

HTTP/1.0 200 OK
Date: Sun, 09 Dec 2007 10:41:00 GMT
X-Powered-By: Servlet 2.4; Tomcat-5.0.28/JBoss-3.2.7 (build: CVSTag=JBoss_3_2_7 date=200501280217)
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_E3F73E4E791CD88AAB1197196860587; type="application/xop+xml"; start="0.urn:uuid:E3F73E4E791CD88AAB1197196860588@apache.org"; start-info="text/xml"
Set-Cookie: BIGipServerhttp_87_integracion= 50571456.22272.0000; path=/
Connection: close

--MIMEBoundaryurn_uuid_E3F73E4E791CD88AAB1197196860587
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:E3F73E4E791CD88AAB1197196860588@apache.org>


The problem is with start attribute, that doesn't match with the content-id of the object root, because it hasn't < and >. According to RFC 2387: "The 'start' parameter, if given, points, via a content-ID, to the
body part that contains the object root."
.
A example from this RFC:

Content-Type: Multipart/Related; boundary=example-1
start="<950120.aaCC@XIson.com>";
type="Application/X-FixedRecord"
start-info="-o ps"

Content-Type: Application/X-FixedRecord
Content-ID: <950120.aaCC@XIson.com>


Here is a link to this issue from Axis2:
https://issues.apache.org/jira/browse/AXIS2-3196.
Here is a link to the culprit version change: http://svn.apache.org/viewvc?view=rev&revision=555276.
Here is a link to the correct version change: http://svn.apache.org/viewvc?view=rev&revision=573037.

Here is the .NET call, that is correct according to RFC:

POST /services/SOAPService HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.1433)
VsDebuggerCausalityData: uIDPo/roRa0+I2ZGg8sva4yaNrAAAAAA0oIuYeGHw0WWedV3KmBPQfNgOTYMehBNh8VxIFQqoJ8ACAAA
SOAPAction: "process"
Host: test.host.com
Content-Type: multipart/related; type="application/xop+xml"; boundary=--MIMEBoundary633327972312845535; start="<0.633327972312845535@example.org>"; start-info="text/xml; charset=utf-8"
Content-Length: 1358
Expect: 100-continue
Proxy-Connection: Keep-Alive

----MIMEBoundary633327972312845535
content-id: <0.633327972312845535@example.org>
content-type: application/xop+xml; charset=utf-8; type="text/xml; charset=utf-8"
content-transfer-encoding: binary

Monday, November 26, 2007

Custom Pipeline FTP Component Error: "Ran out of memory"

We have developed a custom pipeline component that writes in context FTP properties, such as BeforePut, UserName, ...

When we are testing this component we received an unusual error: "Ran out of memory".

After discard memory problems, we realize that our problem was that...Password was not properly setted!!

We set Password FTP Context property ("http://schemas.microsoft.com/BizTalk/2003/ftp-properties") and our "Ran out of memory" error disappears.

Saturday, November 24, 2007

SOA Conference 2007 at Madrid

Next December 4 at Madrid, Microsoft announces SOA Conference 2007 in Spain. My friend Tomás Hernández will talk about "BizTalk Adapters for WCF".

Here is a complete agenda:
http://www.microsoft.com/spain/sunegocioconectado/agenda.aspx

Friday, November 23, 2007

MQSC Adapter error

We have installed MQSC adapter for BizTalk, with WebSphere MQ Client 6, with fixpack 6.0.2.2.

Our MQ Servers are MQ WebSphere 6, one in Z/OS Server and other in a Windows 2003 Server.

When we defined a Receive Location and try to get a message, we received this two errors:

"The adapter "MQSC" raised an error message. Details "Failure encountered while attempting to get message from queue. queue = <QueueName>, queueManager = <QueueManagerName>, reasonCode = 2354"."

"The MQCD structure was not valid. The value of 'Version' field has the value '0'. This value is invalid for the operation requested."

We was investigating in this issue, when we find this post:
http://biztalk.softwareheadlines.com/mqsc-adapter-mqseries-client-adapter-extended-transaction-t3299.html

We try this solution and it works!!

Our channel name (for example CHANN.NAMES.SVRCONN) had sufficient length to produces the error. We change the channel name with a shorter name (CHANN.NAMES) and works ok.

Solution is give a channel name one char less that maximum length.

Wednesday, November 21, 2007

Download the Visual Studio 2008 Express Edition All-in-One DVD

Since few days ago is possible to download Visual Studio 2008 in an ISO image. Here is the link:
http://go.microsoft.com/fwlink/?LinkId=104679

Also for instructions on burning the Visual Studio Express Editions DVD there is this link:
http://www.microsoft.com/express/download/offline.aspx

Thursday, November 15, 2007

Web Parts Personalization Providers

As I say in my previous post, today I found a lot of problems when I deploy my application in an integration environment.

Web Parts Personalization was a problem, because I can't use the default database to store the personalization values.

We found two posible solutions in this links:
http://msdn2.microsoft.com/en-us/library/aa479037.aspx
http://www.kowitz.net/files/source/XmlFilePersonalizationProvider.cs.txt

First of two, allow to store values in a txt file and second allow to store values in an XML files.

Both examples, build a class that derives from ProviderBase class. I use txt file provider, I customize the class, because I need more functionality. For example, I implemented this method that recognize when a user has personalization data:

public override int GetCountOfState(PersonalizationScope scope,
PersonalizationStateQuery query)
{
if (File.Exists(GetPath(query.UsernameToMatch, query.PathToMatch)))
return 1;
else
return 0;
}


It works ok and now, I don't need the default personalization database.

SSO Error - The trust relationship between the primary domain and the trusted domain failed.

Today, when I was deploying my application in an integration environment, I found a lot of problems. First of all was this error message when I deploy my config files into SSO:

SSO AUDIT
Function: CreateApplication
Tracking ID: caa4f99b-8053-4a8a-bfd0-67fcce18e978
Client Computer: server.domain.com (ssomanage.exe:4520)
Client User: DOMAIN\User
Application Name: MyApplication
Error Code: 0x800706FC, The trust relationship between the primary domain and the trusted domain failed.

This error message confuse me, but finally I found the solution and was very simple. My error was that in my application configuration XML file for SSO, I set in appAdminAccount tag, my local account, instead of domain account.

Monday, November 12, 2007

AddressAccessDeniedException - Windows Vista

Due to new security settings in Windows Vista, we get this error "HTTP could not register URL http://+:8081/Greeting. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)" when we try to run a ServiceHost in an HTTP address.

To resolve this, we have to give permissions to our user:

1º) Run Visual Studio 2005 Command Prompt as Administrator.
2º) Execute netsh http add urlacl url=http://+:8081/Greeting user=DOMAIN\user
3º) If we want remove permissions: netsh http delete urlacl url=http://+:8081/Greeting

Monday, October 29, 2007

ESB in a .NET environment

Regarding for information about ESB over .NET environment, I found this two alternatives (see Jesus Rodriguez's WebLog at http://weblogs.asp.net/gsusx/archive/2007/10/09/some-thoughts-on-esb-vs-rest-dynamic-languages.aspx):

Neuron ESB:
http://www.neudesic.com/Main.aspx?SS=7&PE=75

ESB Guidance Toolkit:
http://www.codeplex.com/esb

Now I am studying both alternatives...soon I will tell you my opinion.

Friday, October 26, 2007

Unit Testing Class for Maps

Here is my class for unit testing BizTalk maps:

using Microsoft.XLANGs.BaseTypes;

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.XPath;
using System.Xml.Xsl;

namespace MyNamespace.Test
{
  public class MapsUtil
  {
    public static void CompareMaps(TransformBase map, Stream originStream, Stream expectedStream)
    {
      XslTransform transformation = map.Transform;
      XsltArgumentList transformationArgs = map.TransformArgs;

      MemoryStream outputStream = new MemoryStream();

      XPathDocument xpathDoc = new XPathDocument(originStream);

      transformation.Transform(xpathDoc, transformationArgs, outputStream);

      outputStream.Position = 0;

      StreamUtil.CompareStreams(expectedStream, outputStream);

      expectedStream.Flush();
      expectedStream.Close();
      outputStream.Flush();
      outputStream.Close();
    }
  }
}

And here is an example that uses it:

[Test()]
public void MapTest()
{
  MyMap map = new MyMap();
  TransformBase mapping = (TransformBase)map;

  Stream originStream = DocLoader.LoadStream(MESSAGES_NAMESPACE, "NOOP1.Reply.input.xml");
  Stream expectedStream = DocLoader.LoadStream(MESSAGES_NAMESPACE, "NOOP1.Reply_output.xml");

  MapsUtil.CompareMaps(mapping, originStream, expectedStream);
}

Where CompareStreams is a class for compare two different streams and DocLoader is a class for load resources as streams.

Tuesday, September 25, 2007

Mapping to a XML element with fixed attribute

Few days ago, I had this problem: I want to map a source schema to a destination schema, wich one of his elements has a fixed attribute (an attribute with a value in Fixed property). This element hadn't any input value and had minOccurs=0, but the mapper generates it. Here is an example:

- Source Schema



- Destination Schema



- Map



- XML Result

<ns0:Root xmlns:ns0="http://MappingError.DestinationSchema" />
  <element1>
    <field11>element1_0</field11>
    <field12>element2_0</field12>
  </element1>
  <element2 fixedattribute="FixedValue"/>
  <element3>
    <field31>element3_0</field31>
  </element3>
</ns0:root>

One solution is set for this element, an constant input value false, but my problem was that I had a lot elements with fixed attributes that mustn't be generated.

A solution for this is edit the map with notepad (because we can't edit in Visual Studio Properties Window) and set GenerateDefaultFixedNodes property to "No" (default is "Yes").

If we set this property to "No" the result XML is the correct:

<ns0:Root xmlns:ns0="http://MappingError.DestinationSchema" />
  <element1>
    <field11>element1_0</field11>
    <field12>element2_0</field12>
  </element1>
  <element3>
    <field31>element3_0</field31>
  </element3>
</ns0:root>

BizTalk Server 2006 R2 trial software is available for download

Here is the link from Microsoft TechNet for download a trial version:

http://technet.microsoft.com/en-us/bb738059.aspx

Saturday, September 08, 2007

Developing Pipelines Components Common Errors - UNC Path

When we add a pipeline component to our toolbox and we receive this error message: "You have selected an invalid pipeline component assembly. Please check security settings for the assembly if you are loading it from an UNC path.", probably our pipeline component don't find a referenced dll.


If you get this error, you must ensure that all referenced assemblies by this pipeline component are located under the same directory of our pipeline component dll or in the GAC.

Thursday, September 06, 2007

BizTalk Accelerator for SWIFT 2007 Message Pack

Today, BizTalk Server Team Blog have announced the release to the web of BizTalk Accelerator for SWIFT 2007 Message Pack.

For download:
http://support.microsoft.com/kb/925731/en-us

The Future of BizTalk

Great article from Tomas Restrepo about how BizTalk could evolve, expected improvements in new BizTalk version, the impacts of the possible changes in future migrations to new version, ...

Here is the link:
http://www.winterdom.com/weblog/2007/09/03/TheFutureOfBizTalkWCFWF.aspx

Wednesday, August 29, 2007

Enterprise Single Sign-on Service (SSO) as a configuration store (III)

In this article I will explain how to do a .NET class to get config properties from an SSO Affiliate Application.

First of all, we have to add a reference in our project to this DLL:
Common Files\Enterprise Single Sign-On\SDK\Bin\Microsoft.BizTalk.Interop.SSOClient.dll

Then we have to implement a class that implements IPropertyBag, something like this:

using Microsoft.BizTalk.SSOClient.Interop;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace SSOConfig{
   public class PropertyBag : IPropertyBag
   {
      private Hashtable _hashTable;
      public PropertyBag()
      {
         _hashTable= new Hashtable();
      }
      public void Read(string propName, out object ptrVar, int errorLog)
      {
         ptrVar = _hashTable[propName];
      }
      public void Write(string propName, ref object ptrVar)
      {
         if (_hashTable.ContainsKey(propName))
            _hashTable[propName] = ptrVar;
         else
            _hashTable.Add(propName, ptrVar);
      }
   }
}

Now, we can implement our class that gets properties from our affiliate application:

using Microsoft.BizTalk.SSOClient.Interop;
using System;
using System.Collections.Generic;
using System.Text;

namespace SSOConfig{
   public class SSOSettingsGetter    {

      private const string SSO_APPLICATION_NAME = "My Application";
      private const string SSO_IDENTIFIER_NAME = "ConfigProperties";

      public object GetProperty(string propertyName)
      {
         ISSOConfigStore appStore = new ISSOConfigStore();
         PropertyBag pb = new PropertyBag ();
         appStore.GetConfigInfo(SSO_APPLICATION_NAME, SSO_IDENTIFIER_NAME, SSOFlag.SSO_FLAG_RUNTIME, pb);
         object propertyValue = null;
         pb.Read(propertyName, out propertyValue, 0);
         return propertyValue;
      }
   }
}

Enterprise Single Sign-on Service (SSO) as a configuration store (II)

In previous article, I explained how to create an affiliate application in SSO. The most important thing was this lines:

...
<appAdminAccount>BizTalk Server Administrators</appAdminAccount>
<appUserAccount>BizTalk Application Users</appUserAccount>
...
<flags configStoreApp="yes" allowLocalAccounts="yes" enableApp="yes" />

First lines are important because our user should be under one of previous groups. Last line is important because determine that our application is for configuration.

Now I will explain how to set/get the properties' values from command line. We have to use BTSScnSSOApplicationConfig.exe tool.
The sintaxis for this tool to set a value is:
BTSScnSSOApplicationConfig.exe -set <appName> <id> <propertyName> <propertyValue>
The sintaxis for this tool to get a value is:
BTSScnSSOApplicationConfig.exe -get <appName> <id> <propertyName>

For example, to modify my "db.passwd" value:
BTSScnSSOApplicationConfig.exe -set "My Application" ConfigProperties db.passwd mynewpasswd

To obtain this value:
BTSScnSSOApplicationConfig.exe -get "My Application" ConfigProperties db.passwd

Monday, August 27, 2007

Differences/Similarities between WCF behaviors and BizTalk pipelines

Great Jesus Rodriguez's about wich WCF features are similar to BizTalk pipelines and wich are different, how this features can complement existing BizTalk pipelines features and which overlaps existing pipeline features:
http://weblogs.asp.net/gsusx/archive/2007/08/23/wcf-behavior-vs-pipelines-on-biztalk-server-r2.aspx

Here another article by Tomas Restrepo from a different point of view:
http://www.winterdom.com/weblog/2007/08/25/WCFAndBizTalkMessaging.aspx

Saturday, August 18, 2007

Enterprise Single Sign-on Service (SSO) as a configuration store (I)

If we want store our BizTalk application configuration in SSO, first we have to create our affilitiate application with an XML similar to this:

<sso>
<application name="My Application">
<description>My application description</description>
<contact>felixmondelo@gmail.com</contact>
<appAdminAccount>BizTalk Server Administrators</appAdminAccount>
<appUserAccount>BizTalk Application Users</appUserAccount>
<field ordinal="0" label="reserved" masked="no"/>
<field ordinal="1" label="db.passwd" masked="yes" value="passwd" />
<field ordinal="2" label="db.conn.string" masked="yes" value="Data Source=localhost;Initial Catalog=MyDb;Integrated Security=True" />
<flags configStoreApp="yes" allowLocalAccounts="yes" enableApp="yes" />
</application>
</sso>

For more information about each field in this xml go to http://msdn2.microsoft.com/en-us/library/ms961685.aspx.

Then we have to insert this application into SSO with this executable "%root%\Program Files\Common Files\Enterprise Single Sign-On\ssomanage.exe". Sintaxis to create an application is:
ssomanage.exe -createapps <previous xml document path>, for example:
ssomanage.exe -createapps myssoappconfiguration.xml.

Tuesday, August 14, 2007

Stored Procedure to return a Policy to its editable state

When we publish or deploy a Policy during development, if we want to modificate the Policy we need to create a new version. With this stored procedure, we can unpublish/undeploy our Policy and modificate it:

CREATE PROCEDURE [dbo].[re_setpolicyeditable] (@policyName nvarchar(256),@nMajor bigint, @nMinor bigint)

AS

DECLARE @nRuleSetID AS BIGINT

SET @nRuleSetID = (SELECT nRuleSetID FROM dbo.re_ruleset WHERE strName = @policyName AND nMajor = @nMajor AND nMinor = @nMinor)

IF @nRuleSetID IS NULL BEGIN PRINT 'The Policy [' + @policyName + ' ' + CAST(@nMajor AS nvarchar(10)) + '.' + CAST(@nMinor AS nvarchar(10)) + '] not exists.' RETURN

END

UPDATE dbo.re_ruleset SET nStatus = 0 WHERE nRuleSetID = @nRuleSetID

DELETE FROM dbo.re_deployment_config WHERE nRuleSetID = @nRuleSetID

DELETE FROM dbo.re_tracking_id WHERE nRuleSetID = @nRuleSetID

INSERT INTO dbo.re_deployment_history VALUES (@policyName , 1, 0, 0, getdate())

GO

Friday, August 10, 2007

Microsoft.BizTalk.Component.Utilities.dll (or how to add reference to a dll wich is only in the GAC)

There are some DLLs wich are located only in the GAC, there is no physical file in our computer. Visual Studio does not allow you to add references to components in the GAC.

We have two alternatives:

1) Copy the file from the GAC to a physical file:
copy C:\WINDOWS\assembly\GAC_MSIL\
Microsoft.BizTalk.Component.Utilities\
3.0.1.0__31bf3856ad364e3\
Microsoft.BizTalk.Component.Utilities.dll

2) Unload the project, edit it and add manually the reference:

<itemgroup>
<reference include="Microsoft.BizTalk.Component.Utilities, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<reference include="Microsoft.BizTalk.Pipeline, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<specificversion>False></specificversion>
<hintpath>..\..\lib\Microsoft.BizTalk.Pipeline.dll></hintpath>
</reference>

Wednesday, August 08, 2007

InterchangeId vs MessageId

Here is an excerpt from "Professional Biztalk Server 2006" book explaining wich is the most appropiate identifier for a message in BizTalk:
"The most appropriate identifier to use is the BTS.InterchangeID message context property. The interchange ID is a GUID that is created by the engine. It is flowed automatically by the Messaging Engine as the message passes through the pipeline. You should note that the Message ID is typically not appropriate, since the message may be cloned multiple times during its processing, as described in Chapter 4, and each clone will have a unique Message ID. The Orchestration Engine will also flow the BTS.InterchangeID message context property where it can, although you must flow the property yourself in scenarios in which you create new messages"

NAnt - Error Handling

When an error occurs in a NAnt process, we can execute an error handling task. We only need to set "nant.onfailure" property to point to valid target element in the build file.

Example:

<property name="nant.onfailure" value="myproject.error" />

<target name="myproject.error">
  <call failonerror="false" target="myproject.error.deletetempfiles" />
  <call failonerror="false" target="myproject.error.deletetestcertificates" />
  <call failonerror="false" target="myproject.error.deletesettings" />
</target>