FW: XLANG/s exists operator
Ref: MSDN: XLANG/s Variables and Operators
A recent project I was developing I was required to pull data from either a file location or a FTP location, and based on the filename it was supposed to do something.
I started testing and I came internal SS an XLANG/s error:
Shape name: Decide Type of Password Reset
ShapeId: 56e918c9-c009-4f4a-a722-a3f6c2f7dd55
Exception thrown from: segment 1, progress 15
Inner exception: There is no value associated with the property 'file. ReceivedFileName 'in the message.
I had forgotten to change my code in the demo-shape from testing just the File. ReceivedFileName to something more intelligent.
I started looking at how I cocould change the code. in this case I was pulling the data from an FTP location, so obviusly, the FILE. specified edfilename did not exist in the message context. I thought of writing the code in an expression shape to be like this:
if(inputMsg(BTS.InboundTransportType)=="FILE"){filename=inputMsg(FILE.ReceivedFileName);}else{filename=inputMsg(FTP.ReceivedFileName);}
But I was not satisfied (am I ever ?), I then looked at the XLANG/s operators and after reviewing the exists operator I came up with some different code:
if(FILE.ReceivedFileName exists inputMsg){filename=inputMsg(FILE.ReceivedFileName);}else{filename=inputMsg(FTP.ReceivedFileName);}
Now there is no perceived benefit in using one way of extracting the filename compared to another, but it is just another arrow in the quiver.
--------------------------------------------------
Expression Shape:
System. Diagnostics. Trace. Write (POMsg (BTF2.svc _ deliveryRctRqt_sendTo_address ));
System. Diagnostics. Trace. Write ("----------------------------");
If (BTF2.svc _ commitmentRctRqt_sendTo_address exists POMsg)
{
System. Diagnostics. Trace. Write (POMsg (BTF2.svc _ commitmentRctRqt_sendTo_address ));
}
Else
{
System. Diagnostics. Trace. Write ("POMsg (BTF2.svc _ commitmentRctRqt_sendTo_address) not exists ");
}
-----------------------
Event Type: Error
Event Source: XLANG/s
Event Category: None
Event ID: 10019
Date: 2008/11/13
Time: 13:42:00
User: N/
Computer: upzone
Description:
Uncaught exception (see the 'inner exception' below) has suincluded an instance of service' PurchaseOrderProcessing. POProcess (2e06d80b-27f8-74d1-c2f0-84f2b9468b71 )'.
The service instance will remain susponded until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: 50d1c8c3-d62c-41ef-8e31-4d02778b1370
Shape name: ConstructMessage_1
ShapeId: 0146836d-eb74-4c4e-9e22-1c7c18d17284
Exception thrown from: segment 1, progress 7
Inner exception: There is no value associated with the property 'btf2. svc_commitmentRctRqt_sendTo_address 'in the message.
Exception type: MissingPropertyException
Source: Microsoft. XLANGs. BizTalk. Engine
Target Site: System. Object GetPropertyValueThrows (System. Type)
The following is a stack trace that identifies the location where the exception occured
At Microsoft. BizTalk. XLANGs. BTXEngine. BTXMessage. GetPropertyValueThrows (Type propType)
At PurchaseOrderProcessing. POProcess. segment1 (StopConditions stopOn)
At Microsoft. XLANGs. Core. segmentschedment. RunASegment (Segment s, StopConditions stopCond, Exception & exp)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.