none
Biztalk custom sendpipe line error-[System.Data.MetadataException] = {"Unable to load the specified metadata resource."} RRS feed

  • Question

  • Hi friends,

    I am developing the custom send pipeline.I am using the entity framework model to develop the pipeline.

    The method,it will take the xml file input and its will dynamically look the xpath values in sql table if any thing match in xml document it will replace the values with sql values.

    Method looks like that

                

    public XmlDocument updateMFiles(XmlDocument inMsgXML)
            {
                //XmlDocument doc = new XmlDocument();
                //doc.Load(ms);
                IConfigHelper configHelper = new ConfigHelper();
                //DataEntities db = new DataEntities(configHelper.GetGeneralConfigValue(ConnectionString));

                eConnection = new EntityConnection(configHelper.GetGeneralConfigValue(ConnectionString));
                db = new DataEntities(eConnection);

                IQueryable<mdata> custQuery = db.mdata.AsQueryable<mdata>();
                if (custQuery != null)
                {
                    List<mdata> mList= custQuery.ToList();

                    if (mList!= null && mList.Count > 0)
                    {
                        foreach (mdata mdata in mList)
                        {
                            string xpath = mdata.XPath;
                            //Iterate the all nodes
                            XmlNodeList xnl = inMsgXML.SelectNodes(xpath);
                            foreach (XmlNode node in xnl)
                            {
                                if (node != null)
                                {
                                    node.InnerText = mdata.ReplaceValue;
                                }
                            }

                        }
                    }
                }

                return inMsgXML;
            }

    I develop the custom pipeline component like that,

    public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
            {
               
                {
                   
                  
                    // Check arguments
                    #region Argument Check
                    if (null == pc)
                        throw new ArgumentNullException("pc");
                    if (null == inmsg)
                        throw new ArgumentNullException("inmsg");
                    if (null == inmsg.BodyPart)
                        throw new ArgumentNullException("inmsg.BodyPart");
                    if (null == inmsg.BodyPart.GetOriginalDataStream())
                        throw new ArgumentNullException("inmsg.GetOriginalDataStream");
                    
                    #endregion Argument Check

                    #region IsDisabled
                    //This method gets executed only when enabled property is set in pipeline designer
                    if (!isEnabled)
                    {
                        return inmsg;
                    }
                    #endregion


                    IBaseMessagePart bodyPart = inmsg.BodyPart;
                    bodyPart = inmsg.BodyPart;
                    
                    //string DestPartyName = "";
                    //string DestMessType  = "";

                    if (bodyPart != null)
                    {
                        
                        
                        XmlDocument xDoc = GetOrginalStreamToXML(inmsg);

                        updateMFiles MD = new updateMFiles();
                        MD.updateMFiless(xDoc);
                        
                        byte[] bufferOutgoingMessage = System.Text.ASCIIEncoding.ASCII.GetBytes(xDoc.OuterXml.ToString());
                        System.IO.MemoryStream ms = new System.IO.MemoryStream(bufferOutgoingMessage);
                        inmsg.BodyPart.Data = ms;
                        pc.ResourceTracker.AddResource(ms);
                        return inmsg;

                                       
                        
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    //if (parms != null)
                    //    parms.Clear();
                }

                return inmsg;
            }
             
             private static XmlDocument GetOrginalStreamToXML(IBaseMessage inmsg)
             {
                 //To get Incoming message
                 System.IO.Stream originalStream = inmsg.BodyPart.GetOriginalDataStream();
                 //Working with XDocument
                 XmlDocument xDoc;
                 xDoc = new XmlDocument();
     
                 using (XmlReader reader = XmlReader.Create(originalStream))
                 {
                     reader.MoveToContent();
                     xDoc.Load(reader);
                 }

                 return xDoc;
             }

            #endregion


        }
    }

    When I run the file its giving the Strange error unable to load the specific metadata resources.

    Can any one check the method and pipeline component is correct.

    thanks

    Hk


    hk

    Friday, March 7, 2014 2:29 AM

Answers

  • Code looks fine. You should find a detailed error in event viewer. Please share that one!

    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

    • Marked as answer by Pengzhen Song Monday, March 17, 2014 10:35 AM
    Monday, March 10, 2014 10:19 AM

All replies

  • It seems that your code is fine, it's confused.
    Monday, March 10, 2014 1:16 AM
  • Code looks fine. You should find a detailed error in event viewer. Please share that one!

    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

    • Marked as answer by Pengzhen Song Monday, March 17, 2014 10:35 AM
    Monday, March 10, 2014 10:19 AM