Tuesday, January 25, 2011
Configuration in BizTalk Map
1. Open "BTSNTSvc.exe.config" file from "drive:\Program Files\Microsoft BizTalk Server 2009 ".
2. Add configuration setting there such as -
//appsettings
add value="Data Source=.;Initial Catalog=yourDB;Integrated Security=SSPI" key="STR"
appsettings//
3. In map file, drag and drop script functoid and write following inline c# script.
public string GetConnectionString()
{
string connString=System.Configuration.ConfigurationSettings.AppSettings.Get("STR").ToString();
return connString;
}
4. While using any database related functoid, drag output of script functoid as input in database functoid. And do not forget to put it in correct parameter sequence.
Note: One more last thing, you cannot test config value in map at design time because configuration values are read BTS host at runtime.
Configuration in BizTalk Map
1. Open "BTSNTSvc.exe.config" file from "drive:\Program Files\Microsoft BizTalk Server 2009 ".
2. Add configuration setting there such as -
3. In map file, drag and drop script functoid and write following inline c# script.
public string GetConnectionString()
{
string connString=System.Configuration.ConfigurationSettings.AppSettings.Get("STR").ToString();
return connString;
}
4. While using any database related functoid, drag output of script functoid as input in database functoid. And do not forget to put it in correct parameter sequence.
Note: One more last thing, you cannot test config value in map at design time because configuration values are read BTS host at runtime.
Monday, January 24, 2011
Debatching with xlinq in Receive Pipeline
<_x0032_100>
<_x0032_200>
<_x0032_300>
<_x0032_400>
use the following.
1.Create a disassembler pipeline component.
2.Use the following code in the disassemble stage
public void Disassemble(IPipelineContext pc, IBaseMessage inmsg)
{
try
{
// Clone the message context so we can associate it with the new message later
originalMsgContext = PipelineUtil.CloneMessageContext(inmsg.Context);
// create the xml doc
incomingXML.Load(inmsg.BodyPart.GetOriginalDataStream());
splittedNode = incomingXML.SelectSingleNode(strxpath);
}
catch (Exception ex)
{
throw (ex);
}
}
///
Then in the GetNext use something like this....
public IBaseMessage GetNext(IPipelineContext context)
{
XmlDocument currentMessage = new XmlDocument();
IBaseMessage newMsg = null;
List
StringReader strreadRead = new StringReader(splittedNode.OuterXml);
//XLINQ query with year,renderingid and month
var grouped = from c in System.Xml.Linq.XElement.Load(strreadRead).Elements("serviceline") group c by new { year = c.Element("year").Value, renderingid = c.Element("renderingid").Value, month = c.Element("month").Value } into c select c;
foreach (var serviceline in grouped)
{
string strgroup = "<_x0032_200>";
foreach (var temps in serviceline)
{
strgroup += temps.ToString();
strgroup += "\n";
}
strgroup = strgroup + "";
strdocs.Add(strgroup);
strgroup = string.Empty;
}
if ((strdocs.Count > 0) && (splitCounter < editnode =" incomingXML.SelectSingleNode(strxpath);" fragment =" incomingXML.CreateDocumentFragment();" innerxml =" strdocs[splitCounter];" splitcounter =" splitCounter" memstream =" new" newmsg =" context.GetMessageFactory().CreateMessage();" newmsgpart =" context.GetMessageFactory().CreateMessagePart();" data =" memStream;" iprop =" 0;" val =" originalMsgContext.ReadAt(iProp,">
Friday, January 21, 2011
Consuming Web Services without web references in BizTalk
wsdl /out:[dir]proxy.cs http://localhost/[webservice URI].asmx?wsdl
2 .After generating the proxy class, you can add the proxy class to a .NET Library project, give it a strong name key file, build the project. (Don’t forget to GAC the generated assembly before deploying the BizTalk project).
3.After it is GAC’d, we can configure the send port of the orchestration and supply the AssemblyName
and MethodName
properties for the message context. After the BizTalk Project is deployed, we can configure the send port calling the Web Service. In the Web Service tab, select the assembly which was created before by building the .NET library project containing the proxy class. Select the type name and method name, and in the General tab, specify the Web Service URI.
In this way, you can have more control over the proxy and handle its versioning, and a little change in the Web Service won't make you build deploy the project again.
Custom Pipeline
Pipeline Components Stages :
General Component: (Decode, Encode, Pre-assemble, Resolve Party or Validate )Take one message process message and produce zero or one message
Disassemble Component: Split message, promote custom properties
Assemble Component: Used to wrap message with head or trailer or both
Probe Component: (This is not an independent component. Any pipeline component can implement the IProbeMessage interface if it must support message probing functionality.)
Enables the component to check the beginning part of the message.
Developing General Pipeline Component
General pipeline component implements following interfaces –
a. IBaseComponent Interface
b. IComponentUI Interface
c. IComponent Interface
d. IPersistPropertyBag (Optional. Required when pipeline design time properties are to be defined)
IBaseComponent Interface:
All pipelines implement this interface. Interface provides members which can be implemented to provide information about pipeline.
IBaseComponent Interface Properties:
Description Property. Used to specify small description about pipeline component.
Description is visible on pipeline properties page at design time.
Name Property used to specify name of pipeline component. Name is visible on pipeline properties page at design time.
Version Property used to specify version (example 1.0.0.0) of pipeline component. Visible on pipeline properties page at design time.
IComponentUI Interface:All pipeline components must implement this interface. Members of this interface provide design time support.
IComponentUI Interface Properties:
Icon Property: used to provide icon associated with pipeline component.
Validate Method: This is called by pipeline designer before pipeline compilation to
verify that all configuration properties are correctly set.
IComponent Interface
This is core interface. Member of this interface is implemented for specific message processing/massaging.
IComponent Interface Properties:
Execute Method: Does specific processing/massaging in inbound message and produces output message to be forwarded to next stages of pipeline or message box.
IPersistPropertyBag
Interface provides members which can be used to save and load pipeline design time properties with property bag. This interface is implemented only when pipeline’s design time properties are to be defined.
IpersistPropertyBag Properties:
GetClassID Method: Retrieves the component's globally unique identifying value.
InitNew Method: Initializes any objects needed by the component to use the persisted properties.
Load Method: Used to load property from property bag.
Save Method: Used to save property to property bag.