Wednesday, May 16, 2012

Orchestration exposed as WCF service adds default serialization namespace to incoming and outgoing messages of type String, Int32, ..

If we need to publish an orchestration with message types System.String, System.Int32, ... (simple .NET Classes message types) as WCF service, we have to publish selecting "Publish Schemas as WCF service", instead of "Publish BizTalk orchestrations as WCF service"..


I have developed a simple solution, with an orchestration that receives a System.Int32 message and returns a System.String message:

If we publish this orchestration as WCF service, using "Publish BizTalk orchestrations as WCF service", in the generated WSDL, we will find this messages:

Look that message types are int and string, but both namespaces are

I implemented a simple test C# console application to invoke the WCF service:

When I run this test console application, an unexpected exception is thrown:

<int xmlns=""> was not expected.
Exception type: InvalidOperationException
Source: System.Xml
Target Site: System.Object Read_int()

To avoid this error, we have to publish our solution using "Publish Schemas as WCF service" and include in our project a schema with primitive types, like: 

And then publish our WCF service publishing this schemas as:

In this step, the operation name have to be the same as operation name in orchestration (ReceiveInt32) and in request and response schema type, we have to select our schema with primitive types:


Tuesday, May 15, 2012

WCF HTTPS BizTalk Send Port: "Could not establish secure channel for SSL/TLS with authority '<remote url>'"

I have an application that needs to connect to a https url, after deploying it and test, the send port returns this message:

"System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority '<remote url>'.  System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel."

Usually this error means that remote certificate is not valid, is not well installed, user that runs the send port doesn't have enough permissions, ... but after checking all, the problem still exists.

The send port was configured with basicHttpBinding, transport security mode and clientCredentials behaviour with both certificates, client and server certificates to establish https connection.

The problem was that in my WCF send port configuration, I forget to set clientCredentialType in Security -> Transport...the error message doesn't help:

Tuesday, May 08, 2012

Optional records in a positional flat file

This days I am working with a file with this structure:

AH Record (Mandatory): File's header, with 14 positions + AH identifier (AH12C0OMMTTD6204)
OD Record (Mandatory): 94 positions + OD identifier
EX Record (Mandatory): 6 positions + EX identifier
MN Record (Mandatory): 12 positions + MN identifier
XR Record (Optional): 4 positions + XR identifier
RF Record (Optional): 17 positions + RF identifier
PT Record (Optional): 2 positions + PT identifier

A sample file could be (all data is in the same line):

AH12C0OMMTTD6204OD9200000002                BUY 0001000.00M0ES0112805025    0000000000000090.000CODIGOCLIENTE5  EX040412MN100001000.00PT00

My first try, was to define a flat file schema with:
  • Records for each structure
  • Tag identifiers
  • Min occurs = 0 in optional records 
But the schema didn't work, because Min occurs = 0 doesn't work as I expected.

After reading this post, I try to put optional records inside a Sequence block, with the same properties, now it works as I expected:

Monday, May 07, 2012

Error importing binding file from remote computer "Failed to create 'AdapterName' Transport Component"

Yesterday I was trying to deploy a BizTalk solution from a continuos integration server to our DEV environment. The solution was deployed perfect, but in the import bindings step, I get this error:

"Failed to create 'AdapterName' Transport Component"

Finally I found the solution. The problem was that in my continuos integration server, I haven't installed this adapter, I don't know why, but is needed.

You can get this error using whichever tool that you use: BTSTask, MSBuild extension pack, Deployment Framework for BizTalk...

XLANGPart.LoadFrom - "Value cannot be null. Parameter name: s as MemoryStream"

If we use a .NET library for construct an orchestration message from a Stream data, we need to use the following code:


If we don't use a MemoryStream, we receive the following error:

"Value cannot be null. Parameter name: s as MemoryStream"

We need to copy our stream to a MemoryStream object and then construct the XLANGPart:

MemoryStream someMemoryStream = StreamToMemoryStream(someStream);
orchestrationMessage[0].LoadFrom(someMemoryStream );

This is because the class Microsoft.XLANGs.Core.Value, only accepts MemoryStream objects in their LoadFrom method.