Adding system date time through an expression shape.

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Adding system date time through an expression shape.

Viewing 1 reply thread
  • Author
    Posts
    • #19038

      Hi,
      I am trying to add the system date and time to a message through an expression shape, but I keep getting the following error..

      “Exception thrown from: segment 1, progress 20 Inner exception: ‘2008-03-10T04’ is an unexpected token. The expected token is ‘”‘ or ”’. Line 1, position 17.”

      The code in the expression editor is as follows, where am I going wrong?

      OrderResponse = new System.Xml.XmlDocument();
      OrderResponse.LoadXml(System.String.Format(“<cXML timestamp=”)+System.DateTime.Now.ToString(“yyyy-MM-ddThh:mm:ss”)+” payloadID='[blocked out]’><Response>hello</Response></cXML>”);

      If I take out the System.DateTime.Now.ToString it works fine.

      Thanks in advance.

    • #19039

      OrderResponse.LoadXml(System.String.Format(“<cXML
      timestamp=”)+System.DateTime.Now.ToString(“yyyy-MM-ddThh:mm:ss”)+”
      payloadID='[blocked
      out]’><Response>hello</Response></cXML>”);

      Should be:

       OrderResponse.LoadXml(System.String.Format(“<cXML
      timestamp=”)+String.Format(“{0:s}”, System.DateTime.Now)+”
      payloadID='[blocked
      out]’><Response>hello</Response></cXML>”);

       

      Check these links too:

      http://blog.stevex.net/index.php/string-formatting-in-csharp/ 

       http://msdn2.microsoft.com/en-us/library/1ksz8yb7.aspx

      • #19043

        Hi Greg, Thanks for the reply.

        I now have the following..

        OrderResponse.LoadXml(System.String.Format(“<cXML timestamp=”)+ System.String.Format(“{0:s}”, System.DateTime.Now)+” payloadID='[blocked out]’><Response>hello</Response></cXML>”);

        I had to add System to the front of System.String.Format(“{0:s}”, as Biztalk didn’t like it without it, but I get the same error.. re-built the solution, deployed, re-started host instances, IIS, even the machine!

        • #19046

          If you are ultimately trying to get this:

          OrderResponse.LoadXml(System.String.Format(“<cXML timestamp=”2008-03-11T13:45:12″ payloadID='[blocked out]’><Response>hello</Response></cXML>“);

          Try this instead:

          OrderResponse.LoadXml(System.String.Format(“<cXML timestamp=\”” + System.String.Format(“{0:s}”, System.DateTime.Now) + “\” payloadID='[blocked out]’><Response>hello</Response></cXML>”);

           

          When converted into a string the quotes for timstamp=”” were missing. In order for a double quote to show up in a string you need to escape them with a \

          Let me know if this works. 

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.