Geeks With Blogs

News
Charles Young
A classic mistake in BizTalk is to think that you can control more than you really can through schemas.   For example, although you can specify default values within a schema (say for a attribute value), this has no effect on message construction and output.  Schemas are for validation, mapping, data-typing.etc.   They don't control message construction or value output.

A related issue that came up recently was how to control XML encoding.   BizTalk defaults to UTF-8 for XML encoding, and a client of ours had been trying to change this by modifying their XSDs.   This does not work.  You control XML encoding by using the XML assembler within the send pipeline .   By default, the XML Assembler outputs XML in UTF-8.    If you are using a bespoke pipeline, you can change this behaviour by simply setting the TargetCharset property of the XML Assembler component within Visual Studio.

If your outbound message passes through an orchestration, there is another approach you can use.  In your orchestration, simply introduce an expression shape before the message is sent, or use an appropriate existing message assignment shape and add the following XLANG/s code...

someMessage(XMLNorm.TargetCharset) = "UTF-16";

...where someMessage is an orchestration message object that contains the message you are sending.   This code will set a contextual property on the message that will tell the XML assembler to output UTF-16 rather than UTF-8.   You can use this approach with the 'built-in' XML send pipeline which already contains the XML assembler component.

Posted on Sunday, July 4, 2004 9:55 PM BizTalk Server 2004/2006 | Back to top


Comments on this post: Quick Tip: How to control XML encoding in BizTalk Server 2004

# iso-8859-1
Requesting Gravatar...
Got it working.. make sure TargetCharset is Western-European (1252)
Left by aman on Jul 13, 2004 4:55 PM

# Changing encoding in Biztalk2002
Requesting Gravatar...
How to do it this Biztalk 2002?
Left by Mick on Nov 05, 2004 10:08 AM

# re: Quick Tip: How to control XML encoding in BizTalk Server 2004
Requesting Gravatar...
I am trying to do this tip in a Multi-part message (the message will be send to a web service) and i am not getting the expected result. The encoded that i see in wire is always utf-8.

Any suggestion?

Thanks in advance
Left by BFC on Mar 22, 2005 6:52 PM

# re: Quick Tip: How to control XML encoding in BizTalk Server 2004
Requesting Gravatar...
Hi,
I am sending request(sales order number) to WBI exposed web services's WSDL via Biztalk 2004 orchistration using default SOAP adapater.

The response from WBI contains some danish characters, which are missing by the time I receive them.

When I did the same test using VB.NET client by setting RequestEncoding = System.Text.Encoding.Default, I was able to see complete response with danish characters.

Here is my VB.NET client code:
'Making Direct call to WBI exposed web service WSDL
Dim wbiOrderRqst As New wbiWS.SERVICE_SYNCH_OrderDetails_Content_Request
wbiOrderRqst.SalesOrderNumber = "5831"

'Response object
Dim wbiOrderRspns As New wbiWS.SERVICE_SYNCH_OrderDetails_Content_Response

'Submit object
Dim wbiOrderSubmit As New wbiWS.SERVICE_SYNCH_OrderDetails

wbiOrderSubmit.RequestEncoding = System.Text.Encoding.Default

'Pass request parameter and wait for response here
wbiOrderRspns = wbiOrderSubmit.requestOrderDetails(wbiOrderRqst)

Now, to achieve the same in BTS2004, what am I suppose to do ?

Kindly help me in this.
Left by Satish on Apr 27, 2005 1:08 PM

# re: Quick Tip: How to control XML encoding in BizTalk Server 2004
Requesting Gravatar...
Does anybody know which assembly reference should I include in the project to use the XMLNORM class in Biztalk 2006?

Thanks,
Carlos Junior.
Left by Carlos on Apr 12, 2006 12:32 PM

# re: Quick Tip: How to control XML encoding in BizTalk Server 2004
Requesting Gravatar...
How to change the message encoding in custom pipeline component? Currently I am modifying message in the custom pipeline component and sending it to the send folder with any orchestration being involved. The output message is encoded as UTF-8 and I want to change it to UTF-16. Any help is apreciated.
-N
Left by N on Jul 18, 2007 9:54 PM

# re: Quick Tip: How to control XML encoding in BizTalk Server 2004
Requesting Gravatar...
It is Microsoft.BizTalk.GlobalPropertySchemas. This reference is added automatically when you create BizTalk orchestration project.
Left by wchen on Sep 16, 2008 3:41 PM

Your comment:
 (will show your gravatar)


Copyright © Charles Young | Powered by: GeeksWithBlogs.net