Monday, January 31, 2005
Working with the primitive data types in BizTalk expression editor
So you might define variables such as: myString as string and myNum as integer. You cna do the following:
myString = "123";
myNum = System.Int32.Parse(myString);
but you cannot do the following:
myString = myNum.toString();
You can work around this by using the static methods available...
// format as a 11 digit padded number.
myString = System.String.Format("{0:00000000000}", myNum);
What is also unusual is that DateTime and Timespan doesn't have this restriction, so the following is allowed.
TransDate = System.DateTime.Now;
TimeStamp = TransDate.ToString("yyyy-MM-dd-HH.mm.ss.ffffff");
This post from Charles Yound explains how XLANG/s differs from C# in other ways...
http://geekswithblogs.net/cyoung/articles/3820.aspx
Friday, January 21, 2005
How to send SOAP headers in BizTalk
Here are the steps to set SOAP headers in a web service request using BizTalk Server 2004 (BTS).
1. Make sure your web reference in your BTS project is up to date.
2. Open the Reference.xsd for the wsdl of the web service. Look for the name of the root node for their Soap Header. Here is the example I'm using...
<soap:Header>
<AuthenticationHeader xmlns="http://www.acme.com/WebService/">
<strUserName>string</UserName>
<strPassword>string</Password>
</AuthenticationHeader>
</soap:Header>
3. Copy the name. Close the file.
4. Create a new item for the BTS project. Select "Property Schema" NOT the regular schema.
- In the properties for <schema>,
Change the target NameSpace to http://schemas.microsoft.com/BizTalk/2003/SOAPHeader
- In the properties for the root node,
Rename the root node the same as the one is step 2 ("AuthenticationHeader")
Change the Property Schema Base drop-down to "MessageContextPropertyBase"
5. Save the file as "SoapHeader.xsd" and Close the file. (Update: It doesn't matter what the name is as long as the TYPE NAME property of the xsd file is not the same as the root node name. Otherwise, you'll run into a compilation error)
6. Go to your orchestration. There should be a Construct Message shape that creates the web service request. There should be a shape inside of it - either a Transform or a Message Assignment.
If it is a Transform, add a Message Assignment below that in the SAME Construct Message shape.
If it is a Message Assignment, do nothing as we will reuse the existing one.
7. Edit the Message Assignment from step 6 and add the following as one line....
SampleWS_Request_Msg(MyBizTalkProject.AuthenticationHeader) =
"<ns0:AuthenticationHeader xmlns:ns0=\"http://www.acme.com/WebService/\">
<ns0:UserName>MyName</ns0:UserName>
<ns0:Password>NotSoSecretPassword</ns0:Password>
</ns0:AuthenticationHeader>";
Where
- "SampleWS_Request_Msg" is the message variable name in the Orchestration for the external web service.
- "MyBizTalkProject" is your project name
- "AuthenticationHeader" is the name of the property schema
Note: Once you type the message name and the first parentheses "SampleWS_Request_Msg(" an intellisense drop-down list appears and the property schema you are looking for should appear.
Note 2: There is another option to use an existing SOAP header from another message, but I had to use this approach as the incoming message was a Flat File.
Note 3: If you are using SOAP over standard HTTP, please keep in mind that the above message contents (including SOAP Header) can be clearly viewed by others monitoring internet traffic. I don't advocate this as a security measure - but since this is not my web service, I have to play along.
Wednesday, January 19, 2005
Don't use "transaction" as the name of your root node in an XML schema
This is the type of error to expect in BizTalk...
MyOrchestration.odx(92,52):
error X2254: unexpected keyword: 'transaction'
error X2011: expected 'identifier'
error X2016: unexpected token: '.'
error X2157: '': a part of a non-method messagetype must be of class type
See this msdn article for all of the XLANG/s reserved keywords...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdk/htm/ebiz_prog_orch_nozn.asp
This also led to me figuring out what that language is that BizTalk uses in the expression editor...
Comparing XLANG/s and C#
Tuesday, January 18, 2005
BizTalk - AssemblyName context property was not valid
Here is one particular error
AssemblyName context property was not valid
or
Microsoft.XLANGs.Core.XlangSoapException: An error occurred while processing
the message, refer to the details section for more information
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.VerifyTransport(Envelope env, Int32 operationId, Context ctx) at
Microsoft.XLANGs.Core.Subscription.Receive(Segment s, Context ctx, Envelope&
env, Boolean topOnly) at Microsoft.XLANGs.Core.PortBase.GetMessageId(Subscription subscription, Segment currentSegment, Context cxt, Envelope& env, CachedObject
location) at SCE_FlatFileTest.SCE_flatfile.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)Microsoft.XLANGs.Core.XlangSoapExceptionScoped@SCE_flatfile.SCE_flatfile2dfdb796-dafc-4e08-af1d-683128013b6f
This happened in one of Orchestrations that was trying to submit a request/response message to a web service. I added the web reference already and all schemas matched correctly. What was going on?
Well, the port I specified for the web service had the wrong port type. When I created the port I elected to create a NEW port type instead of selecting an existing one - the one that is automatically created when you add a web service. Doh!!!
Once I made that change, the above errors went away.