Pages

Saturday, May 5, 2012

Not Using "http://namespace#root" as BizTalk Message Type

Not Using "http://namespace#root" as BizTalk Message Type


This has come up twice for me in the past week: once while reading the tech review comments on my own book (due out in April), and again while I was tech reviewing another BizTalk book (due out in July).  That is, we presumptively say that the BizTalk “message type” always equals http://namespace#root when that’s not necessarily true.  Let’s look at two cases demonstrated here.
This first simple case looks at a situation where an XML schema actually has no namespace.  Consider this schema
Perfectly fine schema, no target namespace.  I’ve gone ahead and created another schema (with namespace) and mapped the no-namespace schema to the namespace schema.  After I deploy this solution and create the necessary ports to both pick up and drop off the message, I can stop the send port and observe the context properties of the inbound message.
Notice that my message type is set to ReturnRequest which is the name of the root node of my schema.  Obviously, no namespace is required here.  If I throw my map on the send port, I can also see that the source schema is successfully found and used when mapping to my destination format.
So, for case #1, you can have schemas with no namespace, and the message type for that message traveling through BizTalk is in no worse shape.

Friday, September 30, 2011

Get Localize DAte format

[pass parameters date, language and country and output local datetime]

public static string How2GetLocalizedDate(string INdate, string INlanguage, string INcountry)
 {
  if ((!string.IsNullOrEmpty(INdate)) && ((!string.IsNullOrEmpty(INlanguage))) && (!string.IsNullOrEmpty(INcountry)))
 {
    DateTime dt = DateTime.Parse(INdate);
    // Sets the CurrentCulture property to U.S. English.
    Thread.CurrentThread.CurrentCulture = new CultureInfo(INlanguage + "-" + INcountry);
    // Displays dt, formatted using the ShortDatePattern
    // and the CurrentThread.CurrentCulture.
    return dt.ToLongDateString();
  }
else
{
   return "";
 }
}

Monday, August 8, 2011

The dependent tool 'svcutil.exe' is not found

I compile a new WCF application and upon running gave the error
(WCF Test Client)(debug-startnewInstastance)

"The dependent tool 'svcutil.exe' is not found. "

To solve this problem install the Windows SDK .Net 3.5 Here the link to download it from. Install that and the WCF Test Client should run without error

IF Windows SDK .net 3.5 i already installed on system then
Verify and copy nd paste 'svcutil.exe' at path C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin.Now it should run fine.I suppose that 'svcutil.exe' was erased from machine while installing higher versions of framework. – 

Wednesday, July 20, 2011

Double Integer

Convert integer into double (100) (100.0)
use of N1, N2

public string retDoubleInteger(string Integer)
{
    return (Convert.ToDouble(Integer).ToString("N1"));
}

-----------------------------------------------------------------------------------------------------------
Convert (datetimetype) Date to yyyy/MM/dd (stringtype)format takes care of null or empty dates

public string serviceFormatDate(string inputDate)
   {
       if (!string.IsNullOrEmpty(inputDate))
   {
          System.DateTime date = System.DateTime.Parse(inputDate);
          inputDate = date.ToString("yyyy/MM/dd");
   }
   else
    {
         inputDate = " ";
    }
return inputDate;
}

----------------------------------------------------------------------------------------------------------
String Replace (all is "well") (all is well)

public static string CleanStringanything(string pur)
        {
            return pur.Replace("\"", "");
        }

----------------------------------------------------------------------------------------------------------
Flag status (true)(0)

public string FlagStatus(string strFlagStatus)
{
    if (strFlagStatus== "true")
       {
           return "0";
       }
   else
      {
            return "1";
       }
}

-----------------------------------------------------------------------------------------------------------
Multiple IF conditions return

public static string StatID(string strStatID)
        {
            if (string.Equals(strStatID, "pur"))
            {
                return "A";
            }
            if (string.Equals(strStatID, "sha"))
            {
                return "B";
            }
            if (string.Equals(strStatID, "krt"))
            {
                return "C";
            }
            if (string.Equals(strStatID, "arp"))
            {
                return "D";
            }
            if (string.Equals(strStatID, "mon"))
            {
                return "E";
            }
            return "NOTVALID";
        }
-----------------------------------------------------------------------------------------------------------
Return nd split (5a), (5)(a)

public string ExtractNum(string numcode)
{
           string[] numbers = Regex.Split(numcode, @"\D+");
           string RetNum = "";
foreach (string value in numbers)
{
   if (!string.IsNullOrEmpty(value))
   {
int i = int.Parse(value);
                                RetNum = RetNum + i;
   }
}
return RetNum;
}

--    --    --
public string RetString(string numCD)
{
    return  Regex.Replace(numCD, @"\d", "");
}

------------------------------------------------------------------------------------------------------------
Sometihng abt conversions of date

public string FDate(string inputDate)
    {
      System.DateTime date = System.DateTime.Parse(inputDate);
      return date.ToString("yyyy-MM-dd");
     }
-------------------------------------------------------------------------------------------------------------

same thing we did before

public string ExtractNum(string Dizycode)
{
           string[] numbers = Regex.Split(Dizycode, @"\D+");
           string RetNum = "";
foreach (string value in numbers)
{
   if (!string.IsNullOrEmpty(value))
   {
int i = int.Parse(value);
                                RetNum = RetNum + i;
   }
}
return RetNum;
}

public string RetString(string DizyCD)
        {
            Regex r = new Regex("(?:[^a-z0-9 ]|(?<=['\"])s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
            DizyCD = r.Replace(DizyCD, String.Empty);
            return Regex.Replace(DizyCD, @"\d", "");
        }
-------------------------------------------------------------------------------------------------------------
replace phone ((265)) to (265)
public static string CleanPhoneNumber(string hone)
        {
            return Regex.Replace(hone, @"[\(\)\-\.\s]", "");
        }

------------------------------------------------------------------------------------------------------------
striped off leading zero (0241)(241)
public string reformData(string Data)
{
if (string.IsNullOrEmpty(Data)) return Data;
else if (Data.StartsWith("0")) return Data.Substring(1, Data.Length-1);
else return Data;
}
-------------------------------------------------------------------------------------------------------------
add fix alpha (0245)(E0245)
public string retstrStat(string strStat)
 {
   if (!System.String.IsNullOrEmpty(strStat))
      {
        return "E"+strStat;
      }
  else
    {
       return "";
   }

Tuesday, July 19, 2011

Selecting the flat file disassembling schema dynamically

COMING SOON

Configuring BizTalk Orchestrations to handle un-typed messages

Found one of useful article thought of sharing
A typical orchestration in BizTalk deals with several kinds of messages. A message in BizTalk is always strongly typed. It is usually associated to some schema defined in the project. A Receive/Send shape in an orchestration is tied to a message declared in the Orchestration View. In the case of an un-typed message, the message type is set to 'System.Xml.XmlDocument', instead of a schema type. The class "XmlDocument" is a super class for all XML messages, and hence it can hold any type of XML message and subsequently any type of orchestration message. To summarize, an un-typed message is one whose message type is set to "XmlDocument" in an orchestration
Consider that we are integrating several small messages into a StoreFront application. This application deals with several kinds of messages like "Car", "Music" and "Book". These messages need to be integrated into a "StoreFront" message. So, a designed orchestration would receive several different types of messages. The orchestration in the article is shown below:

In the above orchestration, the "Send" and "Receive" shapes can handle any type of message. It is because the "Receive" shape is associated with a message which is of type "XmlDocument".

The Decision shape separates out the different kinds of messages.

// Message Type consists of TargetNamespace#SchemaRootElementName
InputMessage(BTS.MessageType) ==
// Message Type consists of TargetNamespace#SchemaRootElementName
InputMessage(BTS.MessageType) ==
// Message Type consists of TargetNamespace#SchemaRootElementName
InputMessage(BTS.MessageType) ==
Notice the commonality in the above schemas. A quick explanation of one of the schemas is as follows:
The schema "Car.xsd" has the following properties:
RegID - The registration ID.



Make - The make of the car.
Model - The year of manufacture.
Operation - Can be either "BUY" or "SELL".
ExpectedPrice - The expected price.
The "InputMessage" message is specified in the Receive shape:

The "OutputMessage" message is specified in the Send shape:
The Message Assignment shape has the following lines of code:

Biztalk Port File Name Macros

If you ever wanted to know how to use any other file name macros other than %MessageID% here they are:

%datetime%

Coordinated Universal Time (UTC) date time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).

%datetime_bts2000%

UTC date time in the format YYYYMMDDhhmmsss, where sss means seconds and milliseconds (for example, 199707121035234 means 1997/07/12, 10:35:23 and 400 milliseconds).

%datetime.tz%

Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD, (for example, 1997-07-12T103508+800).

%DestinationParty%

Name of the destination party. The value comes from message the context property BTS.DestinationParty.

%DestinationPartyID%

Identifier of the destination party (GUID). The value comes from the message context property BTS.DestinationPartyID.

%DestinationPartyQualifier%

Qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.

%MessageID%

Globally unique identifier (GUID) of the message in BizTalk Server. The value comes directly from the message context property BTS.MessageID.

%SourceFileName%

Name of the file from where the File adapter read the message. The file name includes extension and excludes the file path, for example, foo.xml. When substituting this property, the File adapter extracts the file name from the absolute file path stored in the FILE.ReceivedFileName context property. If the context property does not have a value, for example, if message was received on an adapter other than File adapter, then the macro will not be substituted and will remain in the file name as is (for example, C:\Drop\%SourceFileName%).

%SourceParty%

Name of the source party from which the File adapter received the message.

%SourcePartyID%

Identifier of the source party (GUID). The value comes from the message context property BTS.SourcePartyID.

%SourcePartyQualifier%

Qualifier of the source party from which the File adapter received the message.

%time%

UTC time in the format hhmmss.

%time.tz%

Local time plus time zone from GMT in the format hhmmssTZD (for example, 124525+530).