西煞魄工厂

posts - 193, comments - 279, trackbacks - 0, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

2008年2月28日



使用BizTalk开发应用系统

 此文献给那些知道BizTalk,但还不知道它能做什么的朋友们!



    项目中要完成一个消息服务中心程序,主要完成接收各个系统发过来的消息,根据不同的消息内容,按特定的方式将提醒消息发送出去。发送方式主要有:email, 短信, 即时消息。
现有资源:SMTP服器,短信网管接口程序,OCS消息转发接口程序。

    看来,三个发送发式的代码都已经完成了。就差这个消息服务中心了!

    想一想,还是用BizTalk吧。开始画图了!!!!....



所做的工作:
在sqlserver上创建了几个表,为了记录消息日志,同时写了对应的几个Insert存储过程。
定义各系统可以传给我什么样的消息!schema. (xsd)
发EMail,直接用BizTalk的SMTP Adapter。
发OC即时消息,直接用MSMQ Adapter,将消息发到它的接收MSMQ中。
发短信,也用MSMQ Adapter,把消息发到短信服务程序的MSMQ中。
中间定义几个消息。
中间定义几个变量。
使用Sql Adapter生成调用使用的消息。
做几个Mapping。
写几行为了显示在Event日志中的C#代码及几个Helper文件。
按需求,画流程图吧!
最后,进行编译、部署、测试。

一切OK !



解决方案:



实际流程图:


运行时对流程执行的监控:




BizTalk代表的概念!


EAI:我用一个简单的流程图,把三个系统(三种消息发送方式)集成在一起了!
SOA:我有一个接收端口,我可以配置这个接收端口从File, FTP,SQL,.... 只要我能访问到的地方读取、监听数据。为你提供转发提醒消息的服务!
ESB:以后,我有更多的流程了,我可以把它们都串起来,完成一件更庞大的工程!



我们的学习团队!

BizTalk Group MSN群 (MSN:group33022@xiaoi.com )
欢迎加入BizTalk Group组织,我们一起提高并进步!

posted @ 2008-02-28 20:36 西煞魄工人 阅读(315) | 评论 (1)编辑




Event Type: Warning
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5740
Date:  2/28/2008
Time:  6:33:04 PM
User:  N/A
Computer: LABS
Description:
The adapter "SQL" raised an error message. Details "HRESULT="0x80040e14" Description="SQLOLEDB Error Description: Ambiguous update, unique identifier required  Transaction aborted "
 <Root xmlns:ns00="urn:schemas-microsoft-com:xml-updategram"><?MSSQLError HResult="0x80040e14" Source="Microsoft OLE DB Provider for SQL Server" Description="SQLOLEDB Error Description: Ambiguous update, unique identifier required  Transaction aborted "?></Root>".

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

 


Event Type: Warning
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5743
Date:  2/28/2008
Time:  6:33:04 PM
User:  N/A
Computer: LABS
Description:
The adapter failed to transmit message going to send port "UpdateSMGPLog" with URL "SQL://labs/NotificationSystem/". It will be retransmitted after the retry interval specified for this Send Port. Details:"HRESULT="0x80040e14" Description="SQLOLEDB Error Description: Ambiguous update, unique identifier required  Transaction aborted "
 <Root xmlns:ns00="urn:schemas-microsoft-com:xml-updategram"><?MSSQLError HResult="0x80040e14" Source="Microsoft OLE DB Provider for SQL Server" Description="SQLOLEDB Error Description: Ambiguous update, unique identifier required  Transaction aborted "?></Root>".

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


通过在流程中转出关键几个Message的Xml,发现, 于用Update的消息,数据不全。

<ns0:UpdateOCSLogRequest xmlns:ns0="http://EIAC.OA.NotificationSystem.UpdateOCSLog">
<ns0:sync>
<ns0:before><ns0:OCSMessageLog></ns0:OCSMessageLog></ns0:before>
<ns0:after><ns0:OCSMessageLog StateID="1"></ns0:OCSMessageLog></ns0:after>
</ns0:sync>
</ns0:UpdateOCSLogRequest>

没有Before条件,这就相当于你的sql语句少东西!
update table set StateID=1 where <??????> 人家不知道去更新谁!

找到错误原因后,把对应的流程代码再进行了一下整理。确定再测试时,这个before已经有数据了。


 


  问题又被解决了!

西煞魄工人

posted @ 2008-02-28 18:43 西煞魄工人 阅读(112) | 评论 (0)编辑


就差提交了,结果点错了,没存就关了!还得重写!!!!


    今日,流程继续开发,把原来的流程增加更多的日志、状态。方便以后查询消息处理结果。但,流程复杂了,问题也就多多了。




Event Type: Error
Event Source: XLANG/s
Event Category: None
Event ID: 10022
Date:  2/28/2008
Time:  5:03:26 PM
User:  N/A
Computer: LABS
Description:
Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'EIAC.OA.NotificationSystem.Orchestrations.Main(a44769cf-20b3-668b-e434-e1b03b6f84c2)'.
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: 7f7a5fc9-882c-41d4-abf1-4098dcf66126
Shape name: Construct msgUpdateOCSLog
ShapeId: 869f1e47-bfc2-46bf-b425-a85cbcc46b06
Exception thrown from: segment 6, progress 2
Inner exception: A failure occurred while evaluating the distinguished field sync.after.OCSMessageLog.StateID against the message part data. The message part data does not contain at least one of the nodes specified by the XPath expression (listed below) that corresponds to the distinguished field. The cause for this error may be that the message part data has not been initialized or that the message part data does not conform to the message part schema. Ensure that the message part data is initialized correctly. XPath expression: /*[local-name()='UpdateOCSLogRequest' and namespace-uri()='http://EIAC.OA.NotificationSystem.UpdateOCSLog']/*[local-name()='sync' and namespace-uri()='http://EIAC.OA.NotificationSystem.UpdateOCSLog']/*[local-name()='after' and namespace-uri()='http://EIAC.OA.NotificationSystem.UpdateOCSLog']/*[local-name()='OCSMessageLog' and namespace-uri()='http://EIAC.OA.NotificationSystem.UpdateOCSLog']/@*[local-name()='StateID' and namespace-uri()='']
       
Exception type: XPathUpdateException
Source: Microsoft.XLANGs.Engine
Target Site: Void SetDistinguishedField(System.String, System.Object)
The following is a stack trace that identifies the location where the exception occured

   at Microsoft.XLANGs.Core.XSDPart.SetDistinguishedField(String dottedPath, Object val)
   at EIAC.OA.NotificationSystem.Orchestrations.Main.segment6(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.





仔细检查一下错误中提到的消息,它的初始化如下



后面有一赋值操作

msgUpdateOCSLogRequest.parameters.sync.after.OCSMessageLog.StateID = m_strStateID;

通过ErrorLog,错误大至就是发生在这里。





    分析一下原因,大至是由于在Mapping中没有对StateID字段赋值,造成它在xml中是不存在的,所以,后面的赋值操作中,用属性去访问时会报错的。如同一个类的成员变量还没有赋值,就去调用这个成员变量的方法一样。



找一个最简单的方法:







    以后,在构造有属性的消息时,把这些性都赋上个初值,也为以后调用时创建便利。

posted @ 2008-02-28 17:56 西煞魄工人 阅读(180) | 评论 (0)编辑