Business Notification XML Issue

mjopatrnymjopatrny Member Posts: 19
Hi -

I'm hoping someone has seen this incident before. I am adding a new notification to my BN setup but every time I send notification lines to the BN app I get the following error in the event log (which keeps repeating):

============================================
Event Type: Error
Event Source: MessageBusAgent
Event Category: None
Event ID: 0
Date: 5/25/2006
Time: 8:54:09 AM
User: N/A
Computer: CAKNAV01
Description:
Unknown error!

System.Xml.XmlException: There are multiple root elements. Line 11, position 2.
at System.Xml.XmlTextReader.ParseRoot()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadNoCollectTextToken()
at System.Xml.XmlValidatingReader.Read()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at Microsoft.BusinessSolutions.Integration.MessageBusAgent.Agent.PublishEvents()
=============================================


I have verified that the XML code is well-formed and the new template format follows the same form and layout of the NAV-supplied templates.

Additionally, how can I stop the "MessageBusAgent" from repeatedly generating the same error message over and over in the Event Log?



Any help is greatly appreciated! ](*,)
Mike Opatrny

Comments

  • ara3nara3n Member Posts: 9,257
    Could you put your xmlport in here. How you've created it? Or put your xml document in here.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • mjopatrnymjopatrny Member Posts: 19
    I created the XMLPort manually. From this I was able to successfully create a template in BN. If you'd like, I can send you the XMLport object via e-mail. I don't think this forum supports attachments.

    My XML code is below. Thanks in advance for the help.


    ============================================
    <?xml version="1.0" encoding="utf-8" ?>
    <Templates>
    <Template>
    <Description>"Looks for checks that have been issued but have not been posted"</Description>
    <LicenseKeys>
    <NavisionGranuleId>
    </NavisionGranuleId>
    </LicenseKeys>
    <NotificationScheme Name="Unposted Checks in Payment Journal"><Components Id="Signable"><EventComponent Name="EventComponent"><Properties><BusinessEntityName>Checks not Posted</BusinessEntityName><BusinessEntitySchema><xs:schema xmlns:tns="urn:odin-businesssolutions-microsoft-com:navision:io:Checks_x005F_x0020_not_x005F_x0020_Posted" targetNamespace="urn:odin-businesssolutions-microsoft-com:navision:io:Checks_x005F_x0020_not_x005F_x0020_Posted" xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="Gen._Journal_Line"><xs:complexType><xs:sequence><xs:element minOccurs="1" maxOccurs="1" name="Journal_Template_Name" type="xs:string" /><xs:element minOccurs="1" maxOccurs="1" name="Line_No." type="xs:integer" /><xs:element minOccurs="1" maxOccurs="1" name="Account_Type" type="xs:integer" /><xs:element minOccurs="1" maxOccurs="1" name="Document_Type" type="xs:integer" /><xs:element minOccurs="1" maxOccurs="1" name="Amount" type="xs:decimal" /><xs:element minOccurs="1" maxOccurs="1" name="Debit_Amount" type="xs:decimal" /><xs:element minOccurs="1" maxOccurs="1" name="Credit_Amount" type="xs:decimal" /></xs:sequence><xs:attribute name="MBS_Navision_URL" type="xs:string" use="required" /></xs:complexType></xs:element></xs:schema></BusinessEntitySchema><EventName>Checks not Posted</EventName></Properties></EventComponent><MessageComponent Name="MessageComponent"><Properties><Body><xsl:stylesheet xmlns:format="urn:schemas-microsoft-com-businesssolutions-business-notification:formatting" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text" /><msxsl:script language="C#" implements-prefix="format" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><![CDATA[ public string AsDate(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDateTime(value), "d", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    public string AsTime(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDateTime(value), "T", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    public string AsDateTime(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDateTime(value), "g", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    public string AsDecimal(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDecimal(value), "n", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    private string Format(IFormattable value, string format, string cultureId) {
    System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(cultureId);
    return value.ToString(format, culture);
    }

    public string Space() {
    return " ";
    }

    public string NewLine() {
    return "\n";
    }]]></msxsl:script><xsl:template match="/">Check in the amount of $<xsl:value-of select="format:AsDecimal(/Gen._Journal_Line/Amount, 'en-US')" /> has not posted</xsl:template></xsl:stylesheet></Body><BodyDesignTimeHtml><design>Check in the amount of $<SPAN class="mergeField" onresizestart="return false" contentEditable="false" onbeforeeditfocus="return false" format="Decimal" bindingNamspaces="" binding="/Gen._Journal_Line/Amount" functoid="MergeField">Amount</SPAN> has not posted</design></BodyDesignTimeHtml><Culture>en-US</Culture><From>busnotify@elg.com</From><Subject><xsl:stylesheet xmlns:format="urn:schemas-microsoft-com-businesssolutions-business-notification:formatting" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text" /><msxsl:script language="C#" implements-prefix="format" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><![CDATA[ public string AsDate(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDateTime(value), "d", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    public string AsTime(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDateTime(value), "T", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    public string AsDateTime(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDateTime(value), "g", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    public string AsDecimal(string value, string cultureId){
    if(value == null || value == "") return "";
    try {
    return Format(XmlConvert.ToDecimal(value), "n", cultureId);
    } catch(FormatException) {
    return value;
    }
    }

    private string Format(IFormattable value, string format, string cultureId) {
    System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(cultureId);
    return value.ToString(format, culture);
    }

    public string Space() {
    return " ";
    }

    public string NewLine() {
    return "\n";
    }]]></msxsl:script><xsl:template match="/">Unposted Checks in Payment Journal</xsl:template></xsl:stylesheet></Subject><SubjectDesignTimeHtml><design>Unposted Checks in Payment Journal</design></SubjectDesignTimeHtml></Properties></MessageComponent><FilterComponent Name="FilterComponent"><Properties><Filter><Lines><FilterLine /></Lines><Query><Expression></Expression><Namespaces /></Query></Filter></Properties></FilterComponent><RecipientsComponent Name="RecipientsComponent"><Properties><AllowExternalRecipients>False</AllowExternalRecipients><ExternalRecipients /><SignUpDescription>Check has been printed but has not posted</SignUpDescription><SignUpPermissions /><SignUpTitle>Uposted Checks</SignUpTitle></Properties></RecipientsComponent></Components><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315&quot; /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1&quot; /><Reference URI="#Signable"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature&quot; /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1&quot; /><DigestValue>v7dKKf5tRAqzRVDWFZ843q0NNFE=</DigestValue></Reference></SignedInfo><SignatureValue>CSDA5RtqbnYDdH2YrslbP4v04mIqluBRQ+8zTdnxHy29KHs4PIOAIjXj6+29eVyaT7I2xwdEpp1jg3M+HHl1RvnVmm9xQT8WBfq8/ShaF/F4NI/sONIyegufSzp3GL40zElxBWhOkM+Q0/WNlGG6eIBtK5ZzPTEdUvceW3kH2Ds=</SignatureValue><KeyInfo><KeyValue xmlns="http://www.w3.org/2000/09/xmldsig#"><RSAKeyValue><Modulus>4VQSzmSDJ3zZ/df6ONZu3GsbrwjZvFeVbv7I8CSZATNjausnWeNdsJaI/OzNZR0IxHbRD+pasU04l+R8EOhM7aDV/D3osX3x9befeGgZo9RGLTTX59Khwur037jrXa92MhnonLkIY7wYhFRGGCQ1Y9b1tS9dcPrk6V40K+Qk1Hs=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></NotificationScheme&gt;
    </Template>
    </Templates>

    ==============================================
    Mike Opatrny
  • ara3nara3n Member Posts: 9,257
    The problem is that your xml file has multiple roots. In xml you can have only one root. In your xml port add a root element.
    root
      parent
        atributes
        atributes
        etc.
       child
       child
    
    
    In your xmlport are you filtering correct what record your are sending?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • mjopatrnymjopatrny Member Posts: 19
    I'm not sure where the "extra" root lies. In my XMLport, I have "Gen.Journal_line" set as indentation <0> and all other elements/attributes set as indentation <1>.

    The format follows that of the template examples and the BN side is able to see the XMLport object. BN was used to generate the initial xml code to which I added the template header/footer lines.

    As far as filtering goes, I am generating a single notification line to send through the XMLport.


    - Mike :?
    Mike Opatrny
  • ara3nara3n Member Posts: 9,257
    Could you save the xml as a file and post it in here?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • mjopatrnymjopatrny Member Posts: 19
    I'm not sure how to post files into mibuso. I don't see any way to do so. If I'm missing something please let me know.

    I'd be happy to e-mail the xml file to you. It's basically the same info that I had included in the earlier thread.
    Mike Opatrny
  • mjopatrnymjopatrny Member Posts: 19
    If you're okay with me e-mailing my xml file to you, my e-mail is mike.opatrny@wolcottgroup.com. I'll just reply with the file.
    Mike Opatrny
  • ara3nara3n Member Posts: 9,257
    Your xml file looks ok. one root you've basically set the property maxoccurance to one. I don't know what else is causing this problem.
    I had to research and found out that Root element can have attributes. So you are ok on that part.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • mjopatrnymjopatrny Member Posts: 19
    Thanks for verifying that I'm not crazy. I've set everything up to match the predefined templates and XMLports. I did submit the issue to MS-NAV support but they consider it to be coding issue which doesn't fall into their realm.
    Mike Opatrny
  • mjopatrnymjopatrny Member Posts: 19
    Rashed -

    I was able to get my problem resolved. Thanks for your help. Apparently, the MessageBusAgent was continually looping through a series of malformed messages I had generated early last week. The BN app was never able to receive the well-formed messages I submitted a few days later. It just kept repeating the ones it had over and over.

    I got help from MS to stop the messages from repeating in the event viewer. Once I cleared the messages, the new notification worked. I cleared the messages by doing the following, per MS:

    1. When you send a notification from Navision. The messages are written in a folder on the client machine. The folder is your Isolated Storage, usually “Documents and Settings\bcox\Local Settings\Application Data\IsolatedStorage” + some auto generated rubbish folders.
    2. The messages are picked up and sent to the BusinessNotificationsMessageBus web service.
    3. The web service places them in the messageStore table on the SQL server.
    4. The NS$BusinessNotificationInstance picks up the message from the messageStore table. It then places the message in the SQL server's transmissionLog table and sends out mails. Each mail is placed in the Business Notification Log in the Event Log.

    Check the IsolatedStorage folder (you may have to dig through a few layers of directories. Also delete the records in the transmission log table in the Business Notification database.
    Mike Opatrny
Sign In or Register to comment.