XLANGs exists operator

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 across 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 decision shape from testing just the File.ReceivedFileName to something more intelligent.

I started looking at how I could change the code. In this case I was pulling the data from an FTP location, so obviously, the FILE.ReceivedFileName 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/A
Computer: upzone
Description:
Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'PurchaseOrderProcessing.POProcess(2e06d80b-27f8-74d1-c2f0-84f2b9468b71)'.
The service instance will remain suspended 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.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

       

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

posted @ 2008-11-14 12:05  upzone  阅读(334)  评论(0编辑  收藏  举报