none
Simple C# Class RRS feed

  • Question

  • Hi All,

    I want to write simple C# Class for my Biztalk application.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using Microsoft.XLANGs.BaseTypes;
    using System.Xml;
    using System.Text;
    
    namespace Subridge.BThelpClass
    {
        public class MessageHelper
        {
            //public static void createBTMessageFromString(string message,XLANGMessage btmessage)
            //{
            //    btmessage[0].LoadFrom(new MessageFactory(Message));
            //}
        
            public static string GetpartyName(XLANGMessage btmessage)
            {
                XmlDocument odc=null;
                try
                {
                    odc=new.XmlDocument();
                    odc.LoadXml(GetpartyNameBody(btmessage));
                    if(odc!=null)
                    {
                       
                        if(odc.SelectSingleNode("//Invoicing")!=null)
                        {
                           
                        if(odc.SelectSingleNode("//Invoicing//Name")!=null)
                            return odc.SelectSingleNode("//Invoicing//Name").InnerText.Trim();
                        }
    
    
        }
    }

    I was passing one XML file so I need to find the 'Invoicing' node then need to find the name..... Where I was doing mistake .

    Could you please help me on this..?

    I am new to C# .

    Thanks your help in advance

    Thanks,

    KKKKKK

    Sunday, July 29, 2012 5:23 PM

Answers

  • Hi Sivara,

    Do you have a namespace defined in the received message with a prefix?

    You will need to include the namespace to the namespace table of the xmlDoc.

    If your target is to retrieve the node value then you can promote the field to a distinguished field in the schema designer, then inside the orchestration , inside an expression shape you can just say : InvoiceMsg.Name

    Hope that helps


    Regards, Mazin - MCTS BizTalk Server 2006

    Monday, July 30, 2012 1:15 PM

All replies

  • Hi Sivara,

    Do you have a namespace defined in the received message with a prefix?

    You will need to include the namespace to the namespace table of the xmlDoc.

    If your target is to retrieve the node value then you can promote the field to a distinguished field in the schema designer, then inside the orchestration , inside an expression shape you can just say : InvoiceMsg.Name

    Hope that helps


    Regards, Mazin - MCTS BizTalk Server 2006

    Monday, July 30, 2012 1:15 PM
  • Check if the Xpath is same as shown in your invoicing element node and replace it with the correct xpath.

    Shashi

    Wednesday, August 1, 2012 1:27 PM
  • By using xsd.exe /c on your schema you can easily create a c# class representation of you schema. BizTalk will implicitly convert between biztalk XLANGMessages and C# classes for you. This means you can make your input parameter a C# class and from BizTalk you pass on a message.

    This makes navigation very easy as you are navigating a strongly typed class instead of navigating with xpath.

    If you prefere to navigate with xpath here is a tip to make sure you get the correct xpath. Open the schema you are accessing in visual studio and navigate to the desired node. When you highlight the node you can get the complete xpath from "Instance XPath"  property. Copy this value into a text editor. You will get a pretty Long string. Edit it to strip out the ' and namespace-uri()" parts, and you will get a more readable string

    /*It will look something like this*/
    /*[local-name()='Invoices' and namespace-uri()='http://MyCompany.Schemas.Invoices']/*[local-name()='Invoice' and namespace-uri()='']
    
    /*Remove namespace statements makeing it look like this*/
    /*[local-name()='Invoices' ]/*[local-name()='Invoice' ]

    Monday, August 6, 2012 7:53 AM