Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Adding system date time through an expression shape.
- This topic has 4 replies, 1 voice, and was last updated 9 years, 10 months ago by
community-content.
-
AuthorPosts
-
-
March 10, 2008 at 9:54 AM #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.
-
March 10, 2008 at 10:20 AM #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/
-
March 11, 2008 at 3:59 AM #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!
-
March 11, 2008 at 6:54 AM #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.
-
March 12, 2008 at 2:37 AM #19051
HI Greg,
Thats worked, thanks for all your help.
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.