﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-中国龍</title><link>http://www.cnblogs.com/huqingyu/</link><description>=============龖:龍腾飞的样子=============</description><language>zh-cn</language><lastBuildDate>Sat, 06 Sep 2008 01:28:02 GMT</lastBuildDate><pubDate>Sat, 06 Sep 2008 01:28:02 GMT</pubDate><ttl>60</ttl><item><title>eclipse tableviewer 编辑功能</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/27/1230937.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Fri, 27 Jun 2008 02:09:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/27/1230937.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1230937.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/27/1230937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1230937.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1230937.html</trackback:ping><description><![CDATA[1. LabelProvider：<BR>isLableProperty要return true<BR>或者就extends jface.viewer的LabelProvider<BR><BR>2.在tableViewer上加Cell Modifier<BR>CusCellModifier cellModifier = new CusCellModifier(tableViewer);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tableViewer.setCellModifier(cellModifier);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tableViewer.setCellEditors(new CellEditor[] {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new ComboBoxCellEditor(table, new String[0]) });<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cellModifier.stickCellEditors();<BR><BR>tableViewer.setColumnProperties(getColumnProperties());<BR><BR>3.CusCellModifier<BR><BR>public class CusCellModifier<BR>&nbsp;&nbsp;&nbsp; implements ICellModifier<BR>{<BR>&nbsp;&nbsp;&nbsp; public void stickCellEditors()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comboBoxCellEditor = (ComboBoxCellEditor)getCellEditorForProperty("AAA");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comboBoxCellEditor.setItems(getItemsForFieldCombo());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setVisibleItemCount("AAA");<BR>&nbsp;&nbsp;&nbsp; }<BR>}<img src ="http://www.cnblogs.com/huqingyu/aggbug/1230937.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42116/" target="_blank">[新闻]消息称MySQL创始人已向Sun提交辞呈</a>]]></description></item><item><title>Google Code Host的使用说明</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/22/1227821.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Sun, 22 Jun 2008 15:14:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/22/1227821.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1227821.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/22/1227821.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1227821.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1227821.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align=center><SPAN lang=EN-US style="FONT-SIZE: 22pt">Google Code Host</SPAN><SPAN style="FONT-SIZE: 22pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的使用说明</SPAN><SPAN lang=EN-US style="FONT-SIZE: 22pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: right" align=right><SPAN lang=EN-US style="COLOR: red; mso-bidi-font-size: 10.5pt">by shootsoft<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: right" align=right><SPAN lang=EN-US style="COLOR: red; mso-bidi-font-size: 10.5pt"><A href="mailto:yinjun@shootsoft.net">yinjun@shootsoft.net</A><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: right" align=right><SPAN lang=EN-US style="COLOR: red; mso-bidi-font-size: 10.5pt"><A href="http://www.shootsoft.net/">http://www.shootsoft.net</A><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></P>
<H1 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 16pt">1. Eclipse</SPAN><SPAN style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 16pt">Subversion</SPAN><SPAN style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用说明</SPAN><SPAN lang=EN-US style="FONT-SIZE: 16pt"><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">开发工具以</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">Eclipse</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">为主，所以</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">Eclipse</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">首先需要安装一个</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">Subversion</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">的插件。参考下面的网址：</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><A style="mso-comment-reference: shootsoft_1"></A><A href="http://www.ibm.com/developerworks/cn/opensource/os-ecl-subversion/"><SPAN style="mso-comment-continuation: 1"><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">http://www.ibm.com/developerworks/cn/opensource/os-ecl-subversion/</SPAN></SPAN></A><A language=JavaScript class=msocomanchor id=_anchor_1 onmouseover="msoCommentShow('_anchor_1','_com_1')" onmouseout="msoCommentHide('_com_1')" href="#_msocom_1" name=_msoanchor_1>[shootsoft1]</A><SPAN class=MsoCommentReference><SPAN lang=EN-US><SPAN style="mso-special-character: comment">&nbsp;</SPAN></SPAN></SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">项目组的所有成员必须都要按照以上的操作安装好插件，并且注册</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">Google</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">的</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">Gmail</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">帐户。</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<H1 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 16pt; mso-bidi-font-size: 10.5pt">2.Google Code Host</SPAN><SPAN style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">说明</SPAN><SPAN lang=EN-US style="FONT-SIZE: 16pt; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">项目组组长到</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><A href="http://code.google.com/hosting/"><FONT color=#800080>http://code.google.com/hosting/</FONT></A></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">创建新项目（</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><A href="http://code.google.com/hosting/createProject">Create a new project</A></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">）过程省略。最后会看到项目的协作平台网址：</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><A href="http://code.google.com/p/group6homework/source">http://code.google.com/p/group6homework/</A></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">。（</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">group6homework</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.5pt">是项目名称）组长创建完成后还需要把组员的帐户添加进来：通过</SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">[</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-weight: bold"><A href="http://code.google.com/p/group6homework/admin"><SPAN style="COLOR: black; TEXT-DECORATION: none; text-underline: none">Administer</SPAN></A>]—[Project Members]</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial; mso-bidi-font-weight: bold">就可以对项目组成员帐户进行管理。</SPAN><B><SPAN lang=EN-US style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt"><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">创建完成后组长需要安装</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><A href="http://tortoisesvn.net/downloads">http://tortoisesvn.net/downloads</A> Subversion</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">的客户端插件进行项目首次的</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt">Check In</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">操作。</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">操作如下：</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">到</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt">Eclipse</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">的项目的</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt">workspace</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">目录下，进入需要协作的项目的目录，比如我的：</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt">D:\shootsoft\GP6Platform<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">单击鼠标右键，选择</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt">[TortoiseSVN]—[Import]</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">然后输入：</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.1pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.55pt"><A style="mso-comment-reference: 番茄花园_2"><TT><B><I><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">https</SPAN></I></B></TT></A><SPAN style="mso-comment-continuation: 2"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">://group6homework.googlecode.com/svn/trunk/</SPAN></TT></SPAN><A language=JavaScript class=msocomanchor id=_anchor_2 onmouseover="msoCommentShow('_anchor_2','_com_2')" onmouseout="msoCommentHide('_com_2')" href="#_msocom_2" name=_msoanchor_2><FONT face=宋体>[番茄花园2]</FONT></A><SPAN class=MsoCommentReference><SPAN lang=EN-US><SPAN style="mso-special-character: comment">&nbsp;</SPAN></SPAN></SPAN><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.1pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.55pt"><TT><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">注意：<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></B></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 42.0pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">l<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></TT><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">这里网址如果你不太清楚可以登录<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><A href="http://code.google.com/p/group6homework/source">http://code.google.com/p/group6homework/source</A>查看<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 42.0pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">l<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></TT><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">Google Code Host使用的密码是随机生成的，如果已经登录Google，可以查看以下网址获得密码：<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><A href="http://code.google.com/hosting/settings"><FONT color=#800080>http://code.google.com/hosting/settings</FONT></A><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">首次登录可能需要安装证书和输入密码。完成后</SPAN></TT><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt">TortoiseSVN</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">就会自动把文件夹</SPAN><SPAN lang=EN-US style="COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">D:\shootsoft\workspace\GP6Platform下的所有文件同步到服务器上去了。<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<H1 style="MARGIN: 0cm 0cm 0pt"><TT><SPAN lang=EN-US style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">3. Google Code Host与Eclipse<o:p></o:p></SPAN></TT></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">Check In操作完成后组长还需要将项目Check Out出来，真正和Eclipse中的项目结合，组员也需要这样做：<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">1.将自己的项目文件夹<B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: red">备份</SPAN></B>并且从Eclipse中删除。需要选择第一项，连同文件夹一起删除。<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">2.按照<A href="http://www.ibm.com/developerworks/cn/opensource/os-ecl-subversion/">http://www.ibm.com/developerworks/cn/opensource/os-ecl-subversion/</A>中的说明进行Import操作，操作结果如下所示：<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 24pt; mso-char-indent-count: 2.0; mso-char-indent-size: 12.0pt"><TT><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt"><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 393.75pt; HEIGHT: 412.5pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image001.png"></v:imagedata></v:shape></SPAN></TT><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">3.这时点击Next按钮，选择第一项，然后点击Finish按钮。<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1026 style="WIDTH: 393.75pt; HEIGHT: 412.5pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image003.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>4.通过Windows菜单，[Show View]—[Other]<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1027 style="WIDTH: 412.5pt; HEIGHT: 288.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image005.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">5.在弹出的新窗口中选择“SVN—SVN资源库”<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1028 style="WIDTH: 210pt; HEIGHT: 294.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image007.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1029 style="WIDTH: 414.75pt; HEIGHT: 153.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image009.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">6.在刚才Import进来的那个资源库上单击鼠标右键，选择“检出为(<U>A</U>)...”<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1030 style="WIDTH: 133.5pt; HEIGHT: 122.25pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image011.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">7.然后在新窗口中中输入项目名称<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1031 style="WIDTH: 393.75pt; HEIGHT: 303.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image013.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">点击“<SPAN lang=EN-US>Finish”按钮。<o:p></o:p></SPAN></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">稍微等待一会儿，程序就会全部下载回来了。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">8.我的Tomcat5补丁放在了D:\Tomcat5补丁目录下，请各位参考我的未知把补丁放置好。<o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">如果导入的项目有红叉叉，在项目上点击鼠标右键，选择“<SPAN lang=EN-US>Close Project”然后再打开就好了。这时可以清楚的看到项目上图标发生了一点点变化：<o:p></o:p></SPAN></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><v:shape id=_x0000_i1032 style="WIDTH: 225.75pt; HEIGHT: 417pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:/DOCUME~1/Test/LOCALS~1/Temp/msoclip1/01/clip_image015.png"></v:imagedata></v:shape><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">在上面的第<SPAN lang=EN-US>3步上，按道理应该可以作为项目可以直接检出，但是我这里操作总是出错，所以只有按照稍微烦琐一点的步骤来操作了。<o:p></o:p></SPAN></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">&nbsp;<o:p></o:p></SPAN></TT></P>
<H1 style="MARGIN: 0cm 0cm 0pt"><TT><SPAN lang=EN-US style="FONT-SIZE: 16pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">4. Subversion的使用<o:p></o:p></SPAN></TT></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果你对某一个文件进行了修改，想要把这个文件提交到服务器上去，就需要在需要提交的文件上单击鼠标右键，通过</SPAN><SPAN lang=EN-US>Team</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">菜单来</SPAN><SPAN lang=EN-US>[</SPAN><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提交</SPAN><SPAN lang=EN-US>]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果你需要把修改过的文件使用服务器上的来覆盖，可以通过</SPAN><SPAN lang=EN-US>Team</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">菜单的</SPAN><SPAN lang=EN-US>[</SPAN><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">更新</SPAN><SPAN lang=EN-US>]</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来进行。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Subversion</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的使用非常简单，但是要深入探究也可以说上几千字，还是建议通过官方或者非官方的教程来学习：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><A href="http://www.baidu.com/s?tn=searches_dg&amp;ie=utf-8&amp;word=subversion+%E6%95%99%E7%A8%8B">http://www.baidu.com/s?tn=searches_dg&amp;ie=utf-8&amp;word=subversion+%E6%95%99%E7%A8%8B</A></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 宋体"><A href="http://www.baidu.com/s?wd=Subversion+Eclipse&amp;cl=3">http://www.baidu.com/s?wd=Subversion+Eclipse&amp;cl=3</A><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<DIV style="mso-element: comment-list">
<HR class=msocomoff align=left width="33%" SIZE=1>

<DIV style="mso-element: comment">
<DIV language=JavaScript class=msocomtxt id=_com_1 onmouseover="msoCommentShow('_anchor_1','_com_1')" onmouseout="msoCommentHide('_com_1')"><SPAN style="mso-comment-author: 尹君"><A name=_msocom_1></A></SPAN>
<P class=MsoCommentText style="MARGIN: 0cm 0cm 0pt"><SPAN class=MsoCommentReference><SPAN lang=EN-US><SPAN style="mso-special-character: comment">&nbsp;<A class=msocomoff href="#_msoanchor_1">[shootsoft1]</A></SPAN></SPAN></SPAN><SPAN lang=EN-US><A href="http://dev2dev.bea.com.cn/techdoc/20060620822.html">http://dev2dev.bea.com.cn/techdoc/20060620822.html</A></SPAN></P>
<P class=MsoCommentText style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">备用地址</SPAN></P></DIV></DIV>
<DIV style="mso-element: comment">
<DIV language=JavaScript class=msocomtxt id=_com_2 onmouseover="msoCommentShow('_anchor_2','_com_2')" onmouseout="msoCommentHide('_com_2')"><SPAN style="mso-comment-author: 番茄花园"><A name=_msocom_2></A></SPAN>
<P class=MsoCommentText style="MARGIN: 0cm 0cm 0pt"><SPAN class=MsoCommentReference><SPAN lang=EN-US><SPAN style="mso-special-character: comment">&nbsp;<A class=msocomoff href="#_msoanchor_2"><FONT face=宋体>[番茄花园2]</FONT></A></SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里正确的网址应该是</SPAN><TT><B><I><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"> <SPAN lang=EN-US><A href="https://group6homework.googlecode.com/svn/trunk/">https<SPAN style="FONT-WEIGHT: normal; FONT-STYLE: normal">://group6homework.googlecode.com/svn/trunk/</SPAN></A></SPAN></SPAN></I></B></TT></P>
<P class=MsoCommentText style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我原来写的是</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.1pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.55pt"><TT><B><I><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">https</SPAN></I></B></TT><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">://group6homework.googlecode.com/svn/trunk/ group6homework --username shootsoft</SPAN></TT><SPAN class=MsoCommentReference><SPAN lang=EN-US><SPAN style="mso-special-character: comment">&nbsp;<A class=msocomoff href="#_msoanchor_2"><FONT face=宋体>[番茄花园2]</FONT></A></SPAN></SPAN></SPAN><TT><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt"><o:p></o:p></SPAN></TT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><TT><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ansi-font-size: 10.5pt">是不正确的。</SPAN></TT></P></DIV></DIV></DIV><img src ="http://www.cnblogs.com/huqingyu/aggbug/1227821.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42115/" target="_blank">[新闻]谷歌Chrome浏览器即将更换LOGO颜色？</a>]]></description></item><item><title>Ant是个好东西[转]</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/22/1227706.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Sun, 22 Jun 2008 09:55:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/22/1227706.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1227706.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/22/1227706.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1227706.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1227706.html</trackback:ping><description><![CDATA[<H1 class=headtit>在Eclipse中使用Ant来自动编译J2me程序</H1>
<H3 class=headaur><A href="http://www.builder.com.cn/" target=_blank>开发者在线 Builder.com.cn</A> 更新时间:<CITE>2007-09-23</CITE>作者：<SPAN>中国IT实验室</SPAN> 来源:中国IT实验室</H3>
<H2 class=headkeyw>本文关键词： <A href="http://www.builder.com.cn/files/list-0-0-74503-1-1.htm" target=_blank>Ant</A> <A href="http://www.builder.com.cn/files/list-0-0-67355-1-1.htm" target=_blank>编程</A> <A href="http://www.builder.com.cn/files/list-0-0-49591-1-1.htm" target=_blank>Java</A> </H2>
<DIV class=artl_con>
<DIV class=wenzhang>
<DIV class=huazhonghua><SPAN id=hua1></SPAN></DIV><BR>　　今天是比较郁闷的一天，一不小心把eclipse的一个j2me项目中的verified/classes目录中的东东删除了。之后才发现eclipse是如何惩罚我的：它再也不会在这个目录中生成class了，呵呵，罢工了我的工。<BR>　　<BR>　　为什么eclipse不是想netbeans那样用ant来编译、运行j2me项目那？？好在本人目前正在研究ant，呵呵，小试牛刀地用了2小时做了个比较完善的ant脚本可以来弥补一下eclipse对我心情的打击了。<BR>　　<BR>　　下面我把这个脚本和源程序（含demo）贡献出来，大家一起研究探讨。<BR>　　<BR>　　完成以下功能:<BR>　　1.建立基本目录框架<BR>　　2.编译src目录中的源文件<BR>　　3.调用preverify.exe对类文件进行验证<BR>　　4.将类文件生成jar包<BR>　　5.调用proguard类对jar包进行混淆，并解压缩<BR>　　6.将经过混淆、解压缩后的类、资源文件生成jar包，复制src目录中的jad文件，完成程序部署<BR>　　7.调用emulator运行程序<BR>　　<BR>　　用法：<BR>　　只需要修改一下CONF.properties文件中的属性：<BR>　　1.midp.lib.dir-WTK的lib目录路径(位于CONF.properties文件中)<BR>　　2.midp.lib.path-根据需要扩展使用的jar(位于CONF.properties文件中)<BR>　　3.programName-生成jar/jad文件的名字<BR>　　在本脚本中可修改的地方:<BR>　　preverify.exe和emulator.exe的具体参数可以根据需要修改。<BR>　　<BR>　　注意:<BR>　　1.src目录中需要有MANIFEST.MF和$.jar文件，这些将用在生成jar和部署程序时.<BR>　　2.res目录中放置使用的png图片文件.<BR>　　<BR>　　附加类库：<BR>　　混淆器类Proguard-位于lib中。<BR>　　<BR>　　文件说明:<BR>　　CONF.properties:配置属性文件<BR>　　GEN.properties:生成MANIFEST.MF和$.jad文件的替换属性文件<BR>　　JAD.tmp:生成jad文件用到的替换模板文件<BR>　　MANIFEST.tmp:生成MANIFEST.MF文件用到的替换模板文件<BR>　　<BR>　　&lt;?xml version="1.0" encoding="GBK"?&gt;<BR>　　&lt;project name="automake" default="end" basedir="."&gt;<BR>　　&lt;property file="CONF.properties"/&gt;<BR>　　&lt;property name="src.dir" value="$src"/&gt;<BR>　　&lt;property name="res.dir" value="$res"/&gt;<BR>　　&lt;property name="build.dir" value="$build"/&gt;<BR>　　&lt;property name="deploy.dir" value="$deploy"/&gt;<BR>　　&lt;property name="package.dir" value="$package"/&gt;<BR>　　&lt;property name="package.extract.dir" value="$extract"/&gt;<BR>　　&lt;property name="preverified.dir" value="$preverified"/&gt;<BR>　　&lt;property name="preverified.noObfusedClass.dir" value="$noObfusedclasses"/&gt;<BR>　　&lt;property name="preverified.obfusedClass.dir" value="$obfusedclasses"/&gt;<BR>　　&lt;property name="preverify.bin" value="$binpreverify.exe"/&gt;<BR>　　&lt;property name="emulator.bin" value="$binemulator.exe"/&gt;<BR>　　&lt;property name="proguard.lib.dir" value="$lib"/&gt;<BR>　　&lt;property name="jad.file" value="$.jad"/&gt;<BR>　　&lt;target name="init" description="初始化环境"&gt;<BR>　　&lt;echo message="初始化目录"/&gt;<BR>　　&lt;delete dir="$"/&gt;<BR>　　&lt;delete dir="$"/&gt;<BR>　　&lt;delete dir="$"/&gt;<BR>　　&lt;delete dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;mkdir dir="$"/&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="complie" depends="init" description="编译"&gt;<BR>　　&lt;echo message="编译程序"/&gt;<BR>　　&lt;javac srcdir="$" destdir="$"&gt;<BR>　　&lt;bootclasspath path="$"/&gt;<BR>　　&lt;classpath&gt;<BR>　　&lt;fileset dir="$" includes="*.jar"/&gt;<BR>　　&lt;/classpath&gt;<BR>　　&lt;/javac&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="verifyForNoObfuscate" description="验证j2me的class，将验证后的class输出到$"&gt;<BR>　　&lt;echo message="验证生成的class，将验证后的class输出到$"/&gt;<BR>　　&lt;exec executable="$" searchpath="false"&gt;<BR>　　&lt;arg line="-classpath $"/&gt;<BR>　　&lt;arg line="-d $"/&gt;<BR>　　&lt;arg line="$"/&gt;<BR>　　&lt;/exec&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="genManifest" description="根据模板属性文件的值生成Manifest文件"&gt;<BR>　　&lt;echo message="根据模板属性文件的值生成Manifest文件"/&gt;<BR>　　&lt;!--<BR>　　使用$替换掉属性文件GEN.properties中的@PROGRAMNAME@<BR>　　--&gt;<BR>　　&lt;replace file="GEN.properties"<BR>　　token="@PROGRAMNAME@"<BR>　　value="$"<BR>　　/&gt;<BR>　　&lt;!--<BR>　　使用GEN.properties文件中的属性值替换掉模板文件MANIFEST.tmp中的对应属性值,<BR>　　将替换后的数据复制到$MANIFEST.MF<BR>　　--&gt;<BR>　　&lt;copy file="MANIFEST.tmp"<BR>　　tofile="$MANIFEST.MF"&gt;<BR>　　&lt;filterset begintoken="@" endtoken="@"&gt;<BR>　　&lt;filtersfile file="GEN.properties"/&gt;<BR>　　&lt;/filterset&gt;<BR>　　&lt;/copy&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="package" description="将class打包，输出到$"&gt;<BR>　　&lt;echo message="将class打包，输出到$"/&gt;<BR>　　&lt;jar basedir="$"<BR>　　jarfile="$$-noObfused.jar"<BR>　　manifest="$MANIFEST.MF"　　　&gt;<BR>　　&lt;fileset dir="$" includes="**/*.png"/&gt;<BR>　　&lt;/jar&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="obfuscate" description="对打包后的jar文件进行混淆,然后解压缩至$"&gt;　　　&lt;echo message="对打包后的jar文件进行混淆,然后解压缩至$"/&gt;<BR>　　&lt;java fork="true" classname="proguard.ProGuard"&gt;<BR>　　&lt;classpath path="$proguard.jar"/&gt;<BR>　　&lt;arg line="-libraryjars $"/&gt;<BR>　　&lt;arg line="-injar $$-noObfused.jar"/&gt;<BR>　　&lt;arg line="-outjar $$-obfused.jar"/&gt;<BR>　　&lt;!--保留MIDlet的类声明不被混淆--&gt;<BR>　　&lt;arg line="-keep 'public class * extends javax.microedition.midlet.MIDlet'"/&gt;<BR>　　&lt;!--打印被保留的类名--&gt;<BR>　　&lt;arg line="-printseeds"/&gt;<BR>　　&lt;/java&gt;<BR>　　&lt;unjar src="$$-obfused.jar"<BR>　　dest="$"　　　/&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="verifyForObfuscate" description="验证被混淆的class，输出到$"&gt;<BR>　　&lt;echo message="验证被混淆的class，输出到$"/&gt;　　　&lt;exec executable="$" searchpath="false"&gt;<BR>　　&lt;arg line="-classpath $"/&gt;<BR>　　&lt;arg line="-d $"/&gt;<BR>　　&lt;arg line="$"/&gt;<BR>　　&lt;/exec&gt;<BR>　　&lt;copy todir="$"&gt;<BR>　　&lt;fileset dir="$" includes="**/*.png"/&gt;<BR>　　&lt;/copy&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="deploy" description="将经过验证的混淆后的class打包，部署在delpoy目录"&gt;<BR>　　&lt;echo message="将经过验证的混淆后的class打包，部署在$目录"/&gt;<BR>　　&lt;jar basedir="$"<BR>　　jarfile="$$.jar"<BR>　　manifest="$MANIFEST.MF"<BR>　　&gt;<BR>　　&lt;fileset dir="$" includes="**/*.class;*.png"/&gt;<BR>　　&lt;/jar&gt;<BR>　　&lt;/target&gt;<BR>　　&lt;target name="genJad" description="在$目录生成JAD文件"&gt;<BR>　　&lt;echo message="在$目录生成JAD文件"/&gt;<BR>　　&lt;length file="$$.jar" property="jarsize"/&gt;<BR>　　&lt;echo message="获得jar文件长度:$"/&gt;<BR>　　&lt;replace file="GEN.properties"<BR>　　token="@JARSIZE@"<BR>　　value="$"<BR>　　/&gt;<BR>　　&lt;replace file="GEN.properties"<BR>　　token="@PROGRAMNAME@"<BR>　　value="$"<BR>　　/&gt;<BR>　　&lt;copy file="JAD.tmp" tofile="$$.jad"&gt;<BR>　　&lt;filterset begintoken="@" endtoken="@"&gt;<BR>　　&lt;filtersfile file="GEN.properties"/&gt;<BR>　　&lt;/filterset&gt;<BR>　　&lt;/copy&gt;<BR>　　&lt;/target&gt;</DIV></DIV><img src ="http://www.cnblogs.com/huqingyu/aggbug/1227706.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42115/" target="_blank">[新闻]谷歌Chrome浏览器即将更换LOGO颜色？</a>]]></description></item><item><title>.NET/FCL 2.0在Serialization方面的增强 </title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/14/1220942.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Fri, 13 Jun 2008 23:52:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/14/1220942.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1220942.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/14/1220942.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1220942.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1220942.html</trackback:ping><description><![CDATA[<P><STRONG>1、支持绑定到非公有方法的委托</STRONG></P>
<P>关于这一点，与其说是个增强，在我看来这似乎是设计思路上略微的转变。具体地说，在.NET 1.x，像这样的代码：</P><PRE><DIV><!-- Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">[Serializable]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Person
<IMG id=Codehighlighter_28_67_Open_Image onclick="this.style.display='none'; Codehighlighter_28_67_Open_Text.style.display='none'; Codehighlighter_28_67_Closed_Image.style.display='inline'; Codehighlighter_28_67_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter_28_67_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_28_67_Closed_Text.style.display='none'; Codehighlighter_28_67_Open_Image.style.display='inline'; Codehighlighter_28_67_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter_28_67_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_28_67_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">event</SPAN><SPAN style="COLOR: #000000"> EventHandler Birthday;
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[] args)
<IMG id=Codehighlighter_102_281_Open_Image onclick="this.style.display='none'; Codehighlighter_102_281_Open_Text.style.display='none'; Codehighlighter_102_281_Closed_Image.style.display='inline'; Codehighlighter_102_281_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter_102_281_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_102_281_Closed_Text.style.display='none'; Codehighlighter_102_281_Open_Image.style.display='inline'; Codehighlighter_102_281_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter_102_281_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_102_281_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> Person p </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Person();
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> p.Birthday </SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> EventHandler(p_Birthday);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> BinaryFormatter bf </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> BinaryFormatter();
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> MemoryStream ms </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> MemoryStream();
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> bf.Serialize(ms, p);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> p_Birthday(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000"> sender, EventArgs e)
<IMG id=Codehighlighter_335_380_Open_Image onclick="this.style.display='none'; Codehighlighter_335_380_Open_Text.style.display='none'; Codehighlighter_335_380_Closed_Image.style.display='inline'; Codehighlighter_335_380_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter_335_380_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_335_380_Closed_Text.style.display='none'; Codehighlighter_335_380_Open_Image.style.display='inline'; Codehighlighter_335_380_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter_335_380_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_335_380_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Birthday is coming!</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV>
</PRE>
<P>会抛出一个这样的异常：</P>
<P><EM>An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll<BR>Additional information: Serialization <FONT color=#000000>will not deserialize delegates to non-public methods</FONT>.</EM></P>
<P>提示信息是很明确的，它不支持绑定到非公有方法（non-public method）的委托。要解决这个问题，你得在p_Birthday方法前加一个public关键字。然而，对于类Person的设计者来说，他不知道事件Birthday将被绑定到什么样的方法之上，所以这带来了一定程度的不确定性。</P>
<P>.NET 2.0已经把这个行为改掉了，这段代码现在可以正常运行。这样，在做序列化/反序列化操作时，这增强了应用程序的稳定性。</P>
<P><STRONG>2、可选字段增强了不同版本的应用程序之间的互操作性</STRONG></P>
<P>.NET/FCL 2.0的System.Runtime.Serialization命名空间引入了一个新的名为OptionalFieldAttribute的特性类：</P>
<P><EM>Specifies that a field can be missing from a serialization stream so that the BinaryFormatter and the SoapFormatter does not throw an exception.</EM></P>
<P><EM>This attribute allows you to specify that new fields in a serializable type (a type to which the SerializableAttribute is applied to) are ignored by the BinaryFormatter or the SoapFormatter. This enables version-tolerant serialization of types created for older versions of an application that serializes data. For example, when the formatters encounter a stream produced by a version that does not include the new fields, no exception is thrown, and the existing data on the older type is processed as normal.</EM></P>
<P>这个feature在新/旧版本的应用程序用.NET Remoting进行互操作时特别有用。新版本的类型可能增加了一些新的字段（而老版本没有），这样，对于旧类型的对象通过序列化得到的数据，当你试图通过反序列化生成新类型的对象时，会发生找不到类型成员的错误。现在，你可以用这个OptionalFieldAttribute特性类标记那些新字段，使新/旧版本的应用程序互相兼容。</P>
<P>需要注意的是，要使新/旧版本的应用程序互相兼容，这个OptionalFieldAttribute特性类只是提供了一个approach而已，它不保证忽略（缺少）一些字段后的对象仍然有正常的行为。显而易见，这就像在运行时突然把一个对象的某个私有字段改成null或0值，谁也不知道将会发生什么事情。所以，使用这个特性类时，还需要有设计方面的保证。</P>
<P>然而，要设计这样一个向后兼容的新类型，就算使用非常senior的程序员再加上非常细心的设计也很难保证不出错 — 特别是类型很复杂的情形。对我来说，不到万不得已是不会冒险使用这个OptionalFieldAttribute的。</P>
<P><STRONG>3、序列化/反序列化事件可以让你更容易地<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">自定义序列化</FONT>行为</STRONG></P>
<P>在.NET 1.x，要<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">自定义序列化</FONT>行为，你得让类型继承<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">ISerializable</FONT>接口（当然还是要应用[Serializable]特性），实现GetObjectData方法和一个反序列化构造函数，像这样：</P><PRE><!-- Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<DIV><IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">[Serializable]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Person : <FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">ISerializable</FONT>
<IMG id=Codehighlighter_44_228_Open_Image onclick="this.style.display='none'; Codehighlighter_44_228_Open_Text.style.display='none'; Codehighlighter_44_228_Closed_Image.style.display='inline'; Codehighlighter_44_228_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter_44_228_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_44_228_Closed_Text.style.display='none'; Codehighlighter_44_228_Open_Image.style.display='inline'; Codehighlighter_44_228_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter_44_228_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_44_228_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Person()
<IMG id=Codehighlighter_64_67_Open_Image onclick="this.style.display='none'; Codehighlighter_64_67_Open_Text.style.display='none'; Codehighlighter_64_67_Closed_Image.style.display='inline'; Codehighlighter_64_67_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_64_67_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_64_67_Closed_Text.style.display='none'; Codehighlighter_64_67_Open_Image.style.display='inline'; Codehighlighter_64_67_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_64_67_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_64_67_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">protected</SPAN><SPAN style="COLOR: #000000"> Person(SerializationInfo info, StreamingContext context)
<IMG id=Codehighlighter_139_142_Open_Image onclick="this.style.display='none'; Codehighlighter_139_142_Open_Text.style.display='none'; Codehighlighter_139_142_Closed_Image.style.display='inline'; Codehighlighter_139_142_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_139_142_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_139_142_Closed_Text.style.display='none'; Codehighlighter_139_142_Open_Image.style.display='inline'; Codehighlighter_139_142_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_139_142_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_139_142_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> GetObjectData(SerializationInfo info, StreamingContext context)
<IMG id=Codehighlighter_223_226_Open_Image onclick="this.style.display='none'; Codehighlighter_223_226_Open_Text.style.display='none'; Codehighlighter_223_226_Closed_Image.style.display='inline'; Codehighlighter_223_226_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_223_226_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_223_226_Closed_Text.style.display='none'; Codehighlighter_223_226_Open_Image.style.display='inline'; Codehighlighter_223_226_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_223_226_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_223_226_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV>
</PRE>
<P>这确实提供了<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">自定义序列化</FONT>/反序列化行为的途径，你可以在GetObjectData方法中向SerializationInfo手工添加任何数据（哪怕不是对象的成员），然后在反序列化构造函数中从SerializationInfo重新取出数据，再手工初始化对象。</P>
<P>这是一个完备的方案，但是有些情况下它未免有点麻烦。</P>
<P>根据我的experiance，需要自己实现<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">ISerializable</FONT>接口的情形，往往是因为<STRONG>“大部分字段可以自动序列化<FONT color=#808080>（比如int、string）</FONT>，而少数字段不支持序列化<FONT color=#808080>（比如Thread、WaitHandle）</FONT>，但这些字段对于对象又是必不可少的”</STRONG>的需求。也就是说，这些不支持序列化的字段在反序列化后仍不允许为空时，你得自己控制序列化/反序列化行为，在反序列化构造函数重新建立它们的实例。</P>
<P>这里的问题是，大部分字段都可以<STRONG>自动</STRONG>序列化的；但是为了少数几个不支持序列化的字段，却需要编写代码为所有字段都进行<STRONG>手工</STRONG>的序列化 — 这些代码不但冗繁，而且容易出错（比如忘掉了处理某个字段）。我一直希望能自己参与<STRONG>自动</STRONG>序列化/反序列化的行为，比如在自动反序列化之后，运行时能自动调用一段我自己的代码，处理那些不支持序列化的字段。</P>
<P>.NET/FCL 2.0满足了我的这个需求，它提供了四个序列化/反序列化事件：OnSerializing、OnSerialized、OnDeserializing、OnDeserialized。它们对应了四个加了Attribute后缀的特性类。这里绑定事件的方法不同于普通.NET事件：事件绑定是通过为方法应用特性来实现的（而不是普通的+=和-=）。不必再详细描述，直接看代码：</P><PRE><DIV><!-- Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">[Serializable]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Person : <FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">ISerializable</FONT>
<IMG id=Codehighlighter_44_808_Open_Image onclick="this.style.display='none'; Codehighlighter_44_808_Open_Text.style.display='none'; Codehighlighter_44_808_Closed_Image.style.display='inline'; Codehighlighter_44_808_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter_44_808_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_44_808_Closed_Text.style.display='none'; Codehighlighter_44_808_Open_Image.style.display='inline'; Codehighlighter_44_808_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter_44_808_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_44_808_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Person()
<IMG id=Codehighlighter_65_68_Open_Image onclick="this.style.display='none'; Codehighlighter_65_68_Open_Text.style.display='none'; Codehighlighter_65_68_Closed_Image.style.display='inline'; Codehighlighter_65_68_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_65_68_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_65_68_Closed_Text.style.display='none'; Codehighlighter_65_68_Open_Image.style.display='inline'; Codehighlighter_65_68_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_65_68_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_65_68_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">protected</SPAN><SPAN style="COLOR: #000000"> Person(SerializationInfo info, StreamingContext context)
<IMG id=Codehighlighter_140_210_Open_Image onclick="this.style.display='none'; Codehighlighter_140_210_Open_Text.style.display='none'; Codehighlighter_140_210_Closed_Image.style.display='inline'; Codehighlighter_140_210_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_140_210_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_140_210_Closed_Text.style.display='none'; Codehighlighter_140_210_Open_Image.style.display='inline'; Codehighlighter_140_210_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_140_210_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_140_210_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>  Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.ctor(SerializationInfo, StreamingContext)</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> GetObjectData(SerializationInfo info, StreamingContext context)
<IMG id=Codehighlighter_291_332_Open_Image onclick="this.style.display='none'; Codehighlighter_291_332_Open_Text.style.display='none'; Codehighlighter_291_332_Closed_Image.style.display='inline'; Codehighlighter_291_332_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_291_332_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_291_332_Closed_Text.style.display='none'; Codehighlighter_291_332_Open_Image.style.display='inline'; Codehighlighter_291_332_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_291_332_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_291_332_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>  Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">GetObjectData</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> [OnSerializing]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> OnSerializing(StreamingContext context)
<IMG id=Codehighlighter_408_449_Open_Image onclick="this.style.display='none'; Codehighlighter_408_449_Open_Text.style.display='none'; Codehighlighter_408_449_Closed_Image.style.display='inline'; Codehighlighter_408_449_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_408_449_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_408_449_Closed_Text.style.display='none'; Codehighlighter_408_449_Open_Image.style.display='inline'; Codehighlighter_408_449_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_408_449_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_408_449_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>  Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">OnSerializing</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> [OnSerialized]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> OnSerialized(StreamingContext context)
<IMG id=Codehighlighter_523_563_Open_Image onclick="this.style.display='none'; Codehighlighter_523_563_Open_Text.style.display='none'; Codehighlighter_523_563_Closed_Image.style.display='inline'; Codehighlighter_523_563_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_523_563_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_523_563_Closed_Text.style.display='none'; Codehighlighter_523_563_Open_Image.style.display='inline'; Codehighlighter_523_563_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_523_563_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_523_563_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>  Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">OnSerialized</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> [OnDeserializing]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> OnDeserializing(StreamingContext context)
<IMG id=Codehighlighter_643_686_Open_Image onclick="this.style.display='none'; Codehighlighter_643_686_Open_Text.style.display='none'; Codehighlighter_643_686_Closed_Image.style.display='inline'; Codehighlighter_643_686_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_643_686_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_643_686_Closed_Text.style.display='none'; Codehighlighter_643_686_Open_Image.style.display='inline'; Codehighlighter_643_686_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_643_686_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_643_686_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>  Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">OnDeserializing</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> [OnDeserialized]
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> OnDeserialized(StreamingContext context)
<IMG id=Codehighlighter_764_806_Open_Image onclick="this.style.display='none'; Codehighlighter_764_806_Open_Text.style.display='none'; Codehighlighter_764_806_Closed_Image.style.display='inline'; Codehighlighter_764_806_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter_764_806_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_764_806_Closed_Text.style.display='none'; Codehighlighter_764_806_Open_Image.style.display='inline'; Codehighlighter_764_806_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter_764_806_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_764_806_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top>  Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">OnDeserialized</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000">
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV>
</PRE><PRE><DIV><!-- Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><SPAN style="COLOR: #000000"><IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[] args)
<IMG id=Codehighlighter_705_892_Open_Image onclick="this.style.display='none'; Codehighlighter_705_892_Open_Text.style.display='none'; Codehighlighter_705_892_Closed_Image.style.display='inline'; Codehighlighter_705_892_Closed_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter_705_892_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter_705_892_Closed_Text.style.display='none'; Codehighlighter_705_892_Open_Image.style.display='inline'; Codehighlighter_705_892_Open_Text.style.display='inline';" alt="" src="http://blog.joycode.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter_705_892_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</SPAN><SPAN id=Codehighlighter_705_892_Open_Text><SPAN style="COLOR: #000000">{
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> BinaryFormatter bf </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> BinaryFormatter();
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> Person p </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Person();
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> MemoryStream ms </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> MemoryStream();
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> bf.Serialize(ms, p);
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> ms.Position </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/InBlock.gif" align=top> p </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> bf.Deserialize(ms) </SPAN><SPAN style="COLOR: #0000ff">as</SPAN><SPAN style="COLOR: #000000"> Person;
<IMG alt="" src="http://blog.joycode.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV>
</PRE>
<P>Console输出：</P>
<P>OnSerializing<BR>GetObjectData<BR>OnSerialized<BR>OnDeserializing<BR>.ctor(SerializationInfo, StreamingContext)<BR>OnDeserialized</P>
<P>这里加了<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">ISerializable</FONT>接口只是为了演示事件发生顺序之用，一般情况下，既然已经使用了这四个事件，那这里是不需要这个<FONT style="COLOR: blue; BACKGROUND-COLOR: yellow">ISerializable</FONT>接口的。</P><img src ="http://www.cnblogs.com/huqingyu/aggbug/1220942.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42101/" target="_blank">[新闻]淘宝网合并阿里妈妈 专家称阿里巴巴或有新战略</a>]]></description></item><item><title>通过SOAP发送附件</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/11/1217993.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Wed, 11 Jun 2008 15:59:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/11/1217993.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1217993.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/11/1217993.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1217993.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1217993.html</trackback:ping><description><![CDATA[<DIV class=Content-body id=logPanel><!--attachment-->
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TBODY>
<TR>
<TD align=left><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1579/SendingAttachmentsWithSOAP.gif"><IMG alt=附件 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&amp;contentType=image%2Fgif&amp;attachment=1579" border=0></A></TD></TR>
<TR>
<TD align=left width="99%"><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1579/SendingAttachmentsWithSOAP.gif">SendingAttachmentsWithSOAP.gif</A>(9.9 K)</TD></TR>
<TR>
<TD align=left><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1580/clip_image001.gif"><IMG alt=附件 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&amp;contentType=image%2Fgif&amp;attachment=1580" border=0></A></TD></TR>
<TR>
<TD align=left width="99%"><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1580/clip_image001.gif">clip_image001.gif</A>(9.2 K)</TD></TR>
<TR>
<TD align=left><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1581/clip_image003.gif"><IMG alt=附件 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&amp;contentType=image%2Fgif&amp;attachment=1581" border=0></A></TD></TR>
<TR>
<TD align=left width="99%"><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1581/clip_image003.gif">clip_image003.gif</A>(16.2 K)</TD></TR>
<TR>
<TD align=left><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1582/clip_image005.gif"><IMG alt=附件 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&amp;contentType=image%2Fgif&amp;attachment=1582" border=0></A></TD></TR>
<TR>
<TD align=left width="99%"><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1582/clip_image005.gif">clip_image005.gif</A>(76.4 K)</TD></TR>
<TR>
<TD align=left><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1583/clip_image007.gif"><IMG alt=附件 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet?attachImage=true&amp;contentType=image%2Fgif&amp;attachment=1583" border=0></A></TD></TR>
<TR>
<TD align=left width="99%"><A href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1583/clip_image007.gif">clip_image007.gif</A>(49.1 K)</TD></TR>
<TR>
<TD style="BORDER-TOP: #ccc 1px solid" colSpan=2>&nbsp;</TD></TR></TBODY></TABLE><A href="http://anotherbug.blog.chinajavaworld.com/entry/3134/0/">切换到幻灯片模式</A><BR><BR><!--attachment end--><B>Sending Attachments with SOAP</B> <BR><BR>
<P>SOAP applications often have to deal with more than just simple messages. The payload for a SOAP message can often include a word processing or PDF document, image, or other binary file. This article explains how to use the Message Transmission Optimization Mechanism (MTOM) to send and receive these messages.</P><BR>
<H2>Prerequisites</H2><BR>
<P>This article uses the WSO2 Web Services Application Server (WSAS.) It is recommended that you download and install WSO2 WSAS 2.0. The article uses the servlet edition installed on Apache Tomcat. Any application server can be used with the servlet version, just follow the installation instructions included with WSO2 WSAS. You don't have to use an application server at all, as WSO2 WSAS works great in a standalone format. WSO2 WSAS requires Java 1.4 or 1.5 but there are no other prerequisites for it. Of course web services and SOAP especially is used, so familiarity with that will help.</P><BR>
<H2>When XML is not enough: binary data</H2><BR>
<P>There are endless ways to send data over the network. There are numerous protocols and data formats. Standardization around SOAP has taken away a lot of the guesswork in sending data between systems. SOAP standardizes the protocol (HTTP) and the data format (XML.) </P><BR>
<P>One of the main criticisms of SOAP is its use of XML. XML is text based. This not only makes for large messages, but makes it incompatible with binary data. For example, let's say your message needs to include an image. This poses a problem when your message format is text. </P><BR><B>Combining binary data with SOAP</B> <BR>
<P>Ok, so you need to send binary data between applications. You'd like to use SOAP, but it's limited to text. So should you just give up on SOAP all together? Of course not, there are too many advantages to SOAP. You just need a way to combine it with binary data. You see web pages do this all the time; it can't be that hard, right? Let's explore some solutions to this problem.</P><BR><B>Naive approaches</B> <BR>
<P>One way you might try is to simply dump the binary into a text node. It might look something like Listing 1.</P><BR>
<P><EM>Listing 1. XML with Binary Data: First Try </EM></P><BR><PRE>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <BR> &lt;message&gt; <BR> 	&lt;data&gt;&lt;!-- binary data goes here --&gt;&lt;/data&gt; <BR> &lt;/message&gt; <BR> </PRE><BR>
<P>Remember that characters are also bytes, just like binary data. An XML parser, whether it's a DOM, SAX, or StAX parser, must use the character set encoding of the document to interpret all the bytes in the document as characters. So our binary data could easily have characters that correspond to reserved XML characters, like &lt; or &gt; or &amp;. Any such byte sequence in text node above will cause the parser on the other side to break. So this approach will not work.</P><BR>
<P>But wait, maybe there's a way to fix this approach. What about using a CDATA block? That will tell the parser to ignore the characters inside the block. This modified approach might look like Listing 2.</P><BR>
<P><EM>Listing 2. XML with Binary: Using CDATA </EM></P><BR><PRE>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <BR> &lt;message&gt; <BR> 	&lt;data&gt;&lt;&lt;![CDATA[ binary data goes here ]]&gt;&lt;/data&gt; <BR> &lt;/message&gt; <BR> </PRE><BR>
<P>Now if we have bytes that would be interpreted as a &gt; (for example,) they will be ignored. However, the parser has to figure out where the CDATA section ends. It does this by looking for the byte sequence corresponding to the characters ]]&gt; . It might seem unlikely, but our binary data could have just such a byte sequence in the middle of it. That would cause any parser to think that the CDATA section had ended and the subsequent characters would be interpreted just like in our first attempt. So that's not going to work either. We need a way to make sure those bytes aren't interpreted at all.</P><BR><B>Base 64 encoding: Works but bloated</B> <BR>
<P>There is a solution to this variant of our problem. One common way to do this is to use Base 64 encoding. This technique has been around (as a standard) since the 80's. It involves using a 64 character “alphabet” consisting of the lower case characters, a-z, the upper case characters, A-Z, the numbers 0-9, and the + and / symbols. Every byte gets mapped to these characters, so there's no way for any byte to get misinterpreted as anything that would choke an XML parser. </P><BR>
<P>So there, problem solved, right? Yes, but … it's a rather inefficient solution. Base 64 encoded binary winds up being, on average, 37% larger (number of bytes) than the raw, non-encoded binary data. In addition, the parser on the other side needs to know about the encoding so that it can decode the payload. One could imagine that if Base 64 encoding was part of the SOAP standard, then there would be some standard way to indicate this SOAP message processors. This is not the case, though. It may be a solution, but it is both inefficient and non-standard. We need something that is both more efficient and standardized.</P><BR><B>SOAP with Attachments: Works but flawed design</B> <BR>
<P>One solution to the problem is to use what is known as SOAP with Attachments. The idea here is to just put the binary data outside the SOAP message completely. Figure 1 provides a nice visualization of this.</P><BR>
<P><STRONG>Figure 1. SOAP with Attachments</STRONG></P><BR>
<P><A title=在新窗口打开图片 href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1580/clip_image001.gif" target=_blank><IMG height=473 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1580/clip_image001.gif" width=500></A></P><BR>
<P>This is very similar to how binary files can be attached to emails. The SOAP message contains a reference to the binary file that is attached to the message. This is both more efficient and standardized, but it has some flaws in its design. The binary attachment is not part of the SOAP message at all. It's similar in a lot of ways to just passing a URI for the binary data and leaving it up to the message processor to retrieve the actual binary data. It presents some real problems for things like WS-Security. Still, this is what was used for a while, until a better solution was proposed: MTOM.</P><BR>
<H2>MTOM: Best of both worlds</H2><BR>
<P>MTOM stands for SOAP Message Transmission Optimization Mechanism. It combines the efficiency of SOAP with Attachments, but it does so without having to break the binary data outside of the SOAP message. How can this be? The key is a technology called XML-binary Optimized Packaging or XOP.</P><BR><B>XOP Explained</B> <BR>
<P>XOP allows binary data to be included as part of the XML Infoset. In fact the XML Infoset becomes a superset of the traditional Infoset known as the XOP Infoset. It allows for the binary data to be stored outside of the XML document, just like in SOAP with Attachments. It uses a special XOP:include element to tell the processor to replace the contents with the referenced binary data, thus encapsulating the logic of discrete storage and retrieval of the binary data. This logic becomes inherent to the XML parser, and allows the SOAP parser to treat the binary data as part of the XML document, with no special retrieval logic. Similarly it allows for a SOAP server to create a SOAP message in a uniform way, no special logic for breaking out that binary data from the SOAP message.</P><BR>
<H2>MTOM in WSO2 WSAS</H2><BR>
<P>We've talked a lot about the need for MTOM and how it should work in theory. It doesn't do us a lot of good without a real implementation. Luckily there's an easy way to get a great MTOM implementation, just use WSO2 WSAS. WSO2 WSAS is built on top of tried and true technologies, including Apache Axis2. Axis2 gives WSO2 WSAS its MTOM implementation. Let's take a look at how to tap into the power of WSAS/Axis2's MTOM implementation.</P><BR><B>Sending an MTOM Message from a Web Service with the Axiom API</B> <BR>
<P>MTOM support on Axis2 builds on the same classes used throughout Axis2. It uses Axis2's Object Model (OM). Axis2 supports both Base 64 encoding and MTOM, and makes it relatively simple to switch between them. Why? Well for very small files, it can actually be more efficient to use Base 64 encoding. </P><BR>
<P>To achieve this seamless switching between optimized and non-optimized transport, Axis2 treats binary data as an XML text node. The only difference is that you need to pass in a javax.activation.DataHandler for accessing the data, as shown in Listing 3.</P><BR>
<P><EM>Listing 3. Adding Binary Data with the Axiom API </EM></P><BR><PRE>OMFactory messageFactory = OMAbstractFactory.getOMFactory(); <BR> OMNamespace ns = messageFactory.createOMNamespace("urn:foo" , "foo"); <BR>  <BR> OMElement binaryElement = messageFactory.createOMElement("payload",ns); <BR> FileDataSource src = new FileDataSource("temp.dat"); <BR> DataHandler handler = new DataHandler(src); <BR> OMText textNode = messageFactory.createOMText(handler, true); <BR> binaryElement.addChild(textNode); <BR> </PRE><BR>
<P>In the example in Listing 3, a javax.activation.FileDataSource is used to provide the DataHandler with access to the binary data. You can use any class that implements the javax.activation.DataSource interface. For example, when working with images, the org.apache.axis2.attachments.ImageDataSource can be used. It implements the DataSource interface and can be more convenient when working with images.</P><BR>
<P>So how does Axis2, and thus WSO2 WSAS, know to use MTOM to optimize the binary data? That is actually what Axis2 will do by default. You can manually override this by adding just one line of code, as shown in Listing 4.</P><BR>
<P><EM>Listing 4. Turning off MTOM </EM></P><BR><PRE>textNode.setOptimize(false);</PRE><BR>
<P>That single line of code will tell Axis2 to not optimize, i.e. don't use MTOM. Thus Axis2 will use Base 64 encoding of the binary data, and it really will be a text node. Otherwise, MTOM will kick in, and an XOP include will be used to optimize the transport of the binary data within the SOAP message.</P><BR><B>Enabling MTOM on the server</B> <BR>
<P>Of course to get all this wonderful, automatically optimized behavior, you do need to enable MTOM. You can do this through your axis2.xml file very easily, as shown in Listing 5.</P><BR>
<P><EM>Listing 5. Enabling MTOM in axis.xml </EM></P><BR><PRE>&lt;parameter name="enableMTOM"&gt;true&lt;/parameter&gt;</PRE><BR>
<P>It can't get anymore painless than that, right? This is a global setting, and is the default setting on WSO2 WSAS. You can actually enable MTOM at four different levels: global, service group, service, and operation. You use the same semantics for each level. You can use the Management Console to manage MTOM at each of these levels. For example of this take a look at Figure 2.</P><BR>
<P><STRONG>Figure 2. Managing MTOM at the Service Group Level</STRONG></P><BR>
<P><A title=在新窗口打开图片 href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1581/clip_image003.gif" target=_blank><IMG height=312 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1581/clip_image003.gif" width=500></A></P><BR>
<P>Here we see MTOM being managed at the Service Group level. Each service in the group can also be individually managed, as shown in Figure 3.</P><BR>
<P><STRONG>Figure 3. Managing MTOM at the Service Level</STRONG></P><BR>
<P><A title=在新窗口打开图片 href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1582/clip_image005.gif" target=_blank><IMG height=551 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1582/clip_image005.gif" width=500></A></P><BR>
<P>Of course each service can have one or more operations. WSAS lets you manage MTOM at that level too, as shown in Figure 4.</P><BR>
<P><STRONG>Figure 4.</STRONG></P><BR>
<P><A title=在新窗口打开图片 href="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1583/clip_image007.gif" target=_blank><IMG height=405 src="http://anotherbug.blog.chinajavaworld.com/servlet/AttachmentServlet/download/123297-3134-1583/clip_image007.gif" width=500></A></P><BR>
<P>Notice that at each level, MTOM has three possible values: true, false, and optional. If the property is set to true, then the service will send an optimized message when necessary, i.e. when binary data is included. If the value is set to false, then optimization will never be used, and Base 64 encoding will be used for any binary data. If it is set to optional, then WSAS will optimize if and only if the request came in was optimized. The type of request will indicate to WSAS if it should use MTOM or not.</P><BR>
<P>Why do we need this kind of flexibility? As mentioned earlier, it is often advantageous to use Base 64 encoding on small files. Thus you could decide that certain operations should use MTOM and others should not. Or you could make it optional on an operation, programmatically do a check for the size of the data being sent, and then choose to override the default MTOM if the file is small. Then you're sending MTOM. Let's take a look at how easy WSAS makes it to send an MTOM message from a web service client.</P><BR><B>Creating a SOAP client that sends MTOM messages</B> <BR>
<P>Sending a MTOM message from a client is just as easy as sending an MTOM message from a web service. Axis2 provides several convenient APIs. An example is shown in Listing 6.</P><BR>
<P><EM>Listing 6. Client code for sending MTOM message </EM></P><BR><PRE>ServiceClient wsClient = new ServiceClient(); <BR> Options clientOptions = new Options(); <BR> clientOptions.setTo(new   EndpointReference("http://some/service")); <BR> clientOptions.setAction("foo"); <BR>        clientOptions.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); <BR> wsClient.setOptions(clientOptions); <BR> </PRE><BR>
<P>As you can see in Listing 6, the key thing to do is to enable MTOM in options for the web service client. Once you do that, then Axis2 will optimize any binary data you send to the web service using MTOM automatically. We've seen how to send MTOM messages from a web service and to a web service, now let's look at how to work with data that has been sent using MTOM.</P><BR><B>Handling an MTOM Message in a Web Service</B> <BR>
<P>Now let's assume you have a web service that accepts binary data as part of a SOAP message from a client. If your web service is running on WSAS, you don't need to do anything special to be able to handle optimized binary data from your clients. Your clients can send SOAP messages that use MTOM or Base 64 encoding. It's all seamless with WSAS. Listing 7 shows an example of receiving optimized data.</P><BR>
<P><EM>Listing 7. Web Service receiving Optimized SOAP </EM></P><BR><PRE>OMElement dataElement; // Optimized element <BR> OMText dataNode = (OMText) dataElement.getFirstOMChild(); <BR> DataHandler handler = (DataHandler) dataNode.getDataHandler(); <BR> InputStream stream = handler.getDataSource().getInputStream(); <BR> // read from the stream, proces data, save to file or database, etc. <BR> </PRE><BR>
<P>As we saw earlier, the Axiom API treats the binary data as a text node. This allows a single API for dealing with optimized and non-optimized (Base 64 encoded) data. You simply access the DataHandler associated to the text node (that contains the binary data) and use that to obtain an InputStream. Once you have the InputStream, you can read all the bytes and process them however you need to. WSAS makes it easy to handle SOAP messages with optimized binary data payloads. Let's take a look at how easy it is to work with MTOM on clients.</P><BR><B>Handling an MTOM Message in a Client</B> <BR>
<P>There's no magic to handling an MTOM web service response. We've already seen how to setup the request. In Figure 8 you see how to deal with a response that contains binary data optimized with MTOM.</P><BR><PRE>ServiceClient wsClient = new ServiceClient(); <BR> Options clientOptions = new Options(); <BR> clientOptions.setTo(new EndpointReference("http://some/service")); <BR> clientOptions.setAction("foo"); <BR> clientOptions.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); <BR> wsClient.setOptions(clientOptions); <BR> OMElement payload; <BR> OMElement response = wsClient.sendReceive(payload); <BR> OMElement dataElement = response.getFirstElement(); <BR> OMText binNode = (OMText) dataElement.getFirstOMChild(); <BR> DataHandler dataHandler2 = (DataHandler) binNode.getDataHandler(); <BR> InputStream stream = dataHandler.getInputStream(); <BR> </PRE><BR>
<P>Again the key here is using the Axiom API. It lets us treat the binary data as a text node, and then use the DataHandler to get an InputStream to the data. Again, once you have the InputStream, you can process the data however you need.</P><BR>
<H2>Summary</H2><BR>
<P>We've seen how MTOM provides the perfect combination of SOAP standardization and efficiency for transporting binary data within a web service message. We've seen how WSO2 WSAS implements the MTOM specification using Axis2. We've taken a look at how to setup both web service servers and clients to both send and receive MTOM optimized messages. Now we have everything we need for adding binary data to our web services using WSO2 WSAS.</P><BR>
<H2>Resources</H2><BR>
<UL><BR>
<LI>You're going to want to download <A href="http://wso2.com/products/wsas/" target=_blank>WSO2 WSAS</A>. <BR>
<LI>Read about <A href="http://ruchith.blogspot.com/2007/07/wso2-wsas-20-released.html" target=_blank>the latest features in WSO2 WSAS 2.0</A>. <BR>
<LI>Learn from and interact with the WSO2 community on <A href="http://wso2.org/wiki/display/wsasjava/Home" target=_blank>the WSAS Wiki</A>. <BR>
<LI>Learn about exposing your services as Web services easily with <A href="http://ws.apache.org/axis2/" target=_blank>Axis2</A>. <BR>
<LI>Learn how Axis2 can enable your SOA designs in the developerWorks article <A href="http://www.ibm.com/developerworks/webservices/library/ws-soa-axis2-1/" target=_blank>SOA with Axis2</A>. <BR>
<LI>Learn all about Axis interoperability with other Web service implementations in <A href="http://tssblog.techtarget.com/index.php/mini-guide-apache-web-services/" target=_blank>this entry in the TSS Interoperability blog</A>. <BR>
<LI>Dive into the AXIOM API in the developerWorks article <A href="http://www.ibm.com/developerworks/xml/library/x-axiom/" target=_blank>Get the most out of XML processing with AXIOM</A>. <BR>
<LI>Read all about XOP and MTOM in this <A href="http://www.mnot.net/blog/2004/02/14/xop" target=_blank>blog entry by Mark Nottingham</A>. <BR>
<LI>Interoperability is the name of the game when it comes to web service, so learn about using MTOM with .NET in the article <A href="http://www.codeproject.com/soap/MTOMWebServices.asp" target=_blank>Sending files in chunks with MTOM Web Services and .NET 2.0</A>. <BR></LI></UL><BR>
<H2>About the Author</H2><BR>
<P>Michael Galpin is an architect at eBay in San Jose, CA. He's been developing software since 1998, and holds a degree in mathematics from the California Institute of Technology.</P></DIV><img src ="http://www.cnblogs.com/huqingyu/aggbug/1217993.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42096/" target="_blank">[新闻]微软研究院发布 AutoCollage - 整理并融合照片</a>]]></description></item><item><title>DataSet在WCF中怎么办?</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/09/1216297.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Mon, 09 Jun 2008 09:47:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/09/1216297.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1216297.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/09/1216297.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1216297.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1216297.html</trackback:ping><description><![CDATA[<BLOCKQUOTE><A name=wp80419></A>
<H2 class=pTitle><A href="http://java.sun.com/webservices/reference/tutorials/wsit/doc/DataBinding.html">http://java.sun.com/webservices/reference/tutorials/wsit/doc/DataBinding.html</A></H2>
<H2 class=pTitle>Data Contracts </H2><A name=wp94343></A>
<P class=pBody>This chapter describes guidelines for&nbsp;&nbsp;: </P>
<DIV class=pSmartList1>
<UL class=pSmartList1><A name=wp94245></A>
<DIV class=pSmartList1>
<LI>Designing a XML schema exposed by a web service starting from Java</LI></DIV><A name=wp94249></A>
<DIV class=pSmartList1>
<LI>Consuming a WCF service generated WSDL/XML schema when designing a Java client or Java web service</LI></DIV><A name=wp94250></A>
<DIV class=pSmartList1>
<LI>Developing a Microsoft WCF client</LI></DIV></UL></DIV><A name=wp97851></A>
<P class=pBody>A WSIT client/service uses JAXB 2.0 for XML serialization, generating XML schemas from Java classes and generating Java classes from XML schemas. A WCF client/service uses either <CODE class=cCode>XmlSerializer</CODE> or <CODE class=cCode>DataContractSerializer</CODE> for like tasks. JAXB 2.0 and the WCF XML serialization mechanisms differ in two fundamental ways. First, JAXB 2.0 supports all of XML schema. .NET's <CODE class=cCode>DataContractSerializer</CODE> and <CODE class=cCode>XmlSerializer</CODE> support different XML schema sets. Second, WCF's <CODE class=cCode>XMLSerializer</CODE>/<CODE class=cCode>DataContractSerializer</CODE> and JAXB 2.0 differ in their mapping of programming language datatypes to XML Schema constructs. As a result, a XML schema generated from a programming language on one platform and consumed on another platform may result in less than developer-friendly bindings. This chapter discusses some of the common databinding differences between the two systems and recommends ways to address them. <BR><BR>二 论坛:<BR><A href="http://forums.java.net/jive/thread.jspa?threadID=23398">http://forums.java.net/jive/thread.jspa?threadID=23398</A><BR><BR>Summary: There are multiple threads related to DataSet in these forums. This is an area that needs some guidelines in general.<BR><BR>First, consider how a DataSet is mapped.<BR><BR></P><PRE>    [DataContract]
    <FONT color=navy><B>public</B></FONT> <FONT color=navy><B>class</B></FONT> Foo <FONT color=navy>{</FONT>
&nbsp;
        [DataMember]
        <FONT color=navy><B>public</B></FONT> DataSet ds;
     <FONT color=navy>}</FONT>
&nbsp;
</PRE>
<P class=pBody><BR><BR>will map to <BR><BR>[ code ]<BR>&lt;xs:complexType name="Foo"&gt;<BR>&lt;xs:sequence&gt;<BR>&lt;xs:element minOccurs="0" name="ds" nillable="true"&gt;<BR>&lt;xs:complexType&gt;<BR>&lt;xs:annotation&gt;<BR>&lt;xs:appinfo&gt;<BR>&lt;ActualType Name="DataSet" Namespace="http://schemas.datacontract.org/2004/07/System.Data" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" /&gt;<BR>&lt;/xs:appinfo&gt;<BR>&lt;/xs:annotation&gt;<BR>&lt;xs:sequence&gt;<BR>&lt;xs:element ref="xs:schema" /&gt;<BR>&lt;xs:any /&gt;<BR>&lt;/xs:sequence&gt;<BR>&lt;/xs:complexType&gt;<BR>&lt;/xs:element&gt;<BR>&lt;/xs:sequence&gt;<BR>&lt;/xs:complexType&gt;<BR>&lt;xs:element name="Foo" nillable="true" type="tns:Foo" /&gt;<BR><BR>[/code]<BR><BR>Notice that &lt;element ref="xs:schema"/&gt; . This will cause wsimport to fail. There is an issue already logged against this. <A href="https://jaxp.dev.java.net/issues/show_bug.cgi?id=14">https://jaxp.dev.java.net/issues/show_bug.cgi?id=14</A> . The generated schema allows the schema to be deferred until runtime ; since a DataSet can be filled at runtime, there is no way of knowing what the schema is at design time.<BR><BR>One way to avoid to this to pass a strongly typed dataset. For example,<BR><BR></P><PRE>[DataContract]
<FONT color=navy><B>public</B></FONT> <FONT color=navy><B>class</B></FONT> Foo <FONT color=navy>{</FONT>
&nbsp;
        [DataMember]
        <FONT color=navy><B>public</B></FONT>  BooksDataSet bds;
<FONT color=navy>}</FONT>
&nbsp;
<FONT color=navy><B>public</B></FONT> <FONT color=navy><B>class</B></FONT> BooksDataSet : DataSet <FONT color=navy>{</FONT>...<FONT color=navy>}</FONT>
&nbsp;
</PRE>
<P class=pBody><BR><BR>This will generate a different schema. Notice that &lt;element ref ="xs:schema"/&gt; is no longer generated. <BR><BR></P><PRE>  &lt;xs:complexType name=<FONT color=red>"Foo"</FONT>&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element minOccurs=<FONT color=red>"0"</FONT> name=<FONT color=red>"bds"</FONT> nillable=<FONT color=red>"true"</FONT> type=<FONT color=red>"tns:BooksDataSet"</FONT> /&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;xs:element name=<FONT color=red>"Foo"</FONT> nillable=<FONT color=red>"true"</FONT> type=<FONT color=red>"tns:Foo"</FONT> /&gt;
  &lt;xs:complexType name=<FONT color=red>"BooksDataSet"</FONT>&gt;
    &lt;xs:sequence&gt;
      &lt;xs:any namespace=<FONT color=red>""</FONT> /&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;xs:element name=<FONT color=red>"BooksDataSet"</FONT> nillable=<FONT color=red>"true"</FONT> type=<FONT color=red>"tns:BooksDataSet"</FONT> /&gt;
</PRE>
<P class=pBody><BR><BR>The above should be consumable by wsimport. However, the object model is driven by the above schema. So one would get java.lang.Object for xs:any.<BR><BR>In short, DataSets work well in MS specific environment but not cross platform.<BR>Other suggestions on the forum and/or elsewhere indicate that other types could be used instead of a strongly typed DataSet - e.g. arrays, XmlNode, or XmlDataDocument.<BR><BR><BR>This is an area where we could use guidlines. Please post your feedback on this thread and I will incorporate it into a future version of the DataContracts chapter<BR>(go to <A href="http://weblogs.java.net/blog/sekhar/archive/2007/02/jaxb_and_wcf_da_2.html">http://weblogs.java.net/blog/sekhar/archive/2007/02/jaxb_and_wcf_da_2.html</A> ; follow the link to Data Contracts chapter).<BR><BR>Message was edited by: sekhar <BR><BR><BR>----------------------------------------<BR>The suggestion was not to expose DataSet to from the .NET service. Instead, map DataSet to another .NET type and expose that datatype. For e.g in your .NET service,<BR>1. Use a strongly typed dataset instead of DataSet (above example).<BR>2. Map DataSet to a jagged array ( e.g. object[][] )<BR>3. Map DataSet to a System.Xml.XmlNode . For e.g.<BR></P><PRE>    DataSet ds;
    <FONT color=darkgreen>//... fill in dataset</FONT>
    XmlNode xmlnode = <FONT color=navy><B>new</B></FONT> XmlDataDocument( ds );
   
</PRE>
<P class=pBody><BR>&nbsp;</P></BLOCKQUOTE><img src ="http://www.cnblogs.com/huqingyu/aggbug/1216297.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42100/" target="_blank">[新闻]2008年9月5日科技博客精选</a>]]></description></item><item><title>Oracle App Client use Mtom</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/08/1216002.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Sun, 08 Jun 2008 11:22:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/08/1216002.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1216002.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/08/1216002.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1216002.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1216002.html</trackback:ping><description><![CDATA[<H2>MTOM interoperability between Oracle App Server and Sun WSIT</H2>
<P mce_keep="true">A few months ago I wrote a couple of articles (<A href="http://weblogs.asp.net/gsusx/archive/2006/12/14/mtom-interoperability-between-oracle-application-server-and-windows-communication-foundation-part1-from-wcf-to-oracle.aspx">WCF-ORA</A>, <A href="http://weblogs.asp.net/gsusx/archive/2006/12/19/mtom-interoperability-between-oracle-application-server-and-windows-communication-foundation-part2-from-oracle-to-wcf.aspx">ORA-WCF</A>) about Message Transmission Optimization Mechanism (MTOM) interoperability between Oracle Application Server and Microsoft Windows Communication Foundation (WCF).&nbsp; Most of the feedback I got from those posts was related with MTOM interoperability scenarios using other Web Service technologies toolkits. Based on that, I decided to post a few more demos that reflect MTOM interoperability scenarios for different vendors. Specifically, this paper shows how to achieve MTOM interoperability between Oracle App Server and Sun Web Service Interoperability Technology (WSIT - Project Tango).&nbsp; Believe it or not, I am sorry .NET developers; there is no .NET code in this paper.</P>
<P>This post does not intend to provide a formal introduction to MTOM. Suffice to say that after a few years and three predecessors' specifications, MTOM has become the preferred Standard for SOAP-encoded binary messaging optimization. MTOM relies on the XML Optimized Processing (XOP) Standard as the serialization mechanism to represent binary data as a MIME/Multipart Related package. If you are interested in the importance of MTOM interoperability you might want to read my <A href="http://weblogs.asp.net/gsusx/archive/2006/12/14/mtom-interoperability-between-oracle-application-server-and-windows-communication-foundation-part1-from-wcf-to-oracle.aspx">previous paper</A> or this <A href="http://blogs.msdn.com/jevdemon/archive/2005/05/05/415126.aspx">post</A> by <A href="http://blogs.msdn.com/jevdemon/default.aspx">John Evdemon</A>. </P>
<P><B>Sun WSIT and MTOM</B></P>
<P>WSIT is part of Project Metro which is the Web Services stack from Sun Microsystems. Specifically, WSIT is the component of Project Metro that implements some of the most important WS-* protocols emphasizing in interoperability with Microsoft WCF. Needless to say, that WSIT also interoperates really well with other Web Services technologies including Oracle App Server. At the moment WSIT implements some of the most important WS-* protocols for areas such as Security, Reliability, Transactions and messaging optimization (a.k.a MTOM). The typical scenarios for applying MTOM are Web Services that handles binary data like <B><I>byte[]</I></B> as part of their contract. The following code illustrates a WSIT Service that can be highly optimized with the use of MTOM. </P>
<TABLE class="" cellPadding=0 width="100%" border=1>
<TBODY>
<TR>
<TD class="">
<P>@WebService()<BR>public class FileWS {<BR><BR>@WebMethod(action="PrintFileContents")<BR>public int PrintFileContents(byte[] buffer)<BR>{<BR>for(int i=0; i&lt;= buffer.length - 1; i++)<BR>System.out.println(buffer[i]);<BR>return buffer.length;<BR>}<BR>}</P></TD></TR></TBODY></TABLE>
<P>&nbsp;Now we need to configure the service policy in order to optimize the message exchange using MTOM.&nbsp; The trick here, in order to achieve interoperability with Oracle App Server, is to remove the default WSIT WS-Addressing settings. This is due to the fact that Oracle App Server and Sun WSIT implement different versions of WS-Addressing. The change is not required if the client side supports MTOM with WS-Addressing 1.0 like WCF does. Also, If you are using a development IDE such as NetBeans there is no need to manually configure the policy except for removing the use of WS-Addressing; instead you can the Web Service configuration editor which provides a nice interface for configuring the different WS-* protocols for a particular service. </P>
<TABLE class="" cellPadding=0 width="100%" border=1>
<TBODY>
<TR>
<TD class="">
<P>&lt;definitions <BR>xmlns="http://schemas.xmlsoap.org/wsdl/" <BR>xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" <BR>xmlns:xsd="http://www.w3.org/2001/XMLSchema" <BR>xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="FileWSService" targetNamespace="http://mtomws/" xmlns:tns="http://mtomws/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsaws="http://www.w3.org/2005/08/addressing" xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" <BR>&gt;<BR><B><I>WSDL components....</I></B><BR>&lt;wsp:Policy wsu:Id="FileWSPortBindingPolicy"&gt;<BR>&lt;wsp:ExactlyOne&gt;<BR>&lt;wsp:All&gt;<BR><B><I>&lt;!-- &lt;wsaws:UsingAddressing xmlns:wsaws="http://www.w3.org/2006/05/addressing/wsdl"/&gt;--&gt;</I></B><B><I><BR></I></B><B><I>&lt;wsoma:OptimizedMimeSerialization/&gt;</I></B><BR>&lt;/wsp:All&gt;<BR>&lt;/wsp:ExactlyOne&gt;<BR>&lt;/wsp:Policy&gt;<BR>&lt;/definitions&gt;</P></TD></TR></TBODY></TABLE>
<P>Now we are ready to deploy the service, for the purposes of this demo we used Sun Glassfish.</P>
<P><B>Oracle App Server and MTOM</B></P>
<P>Now it's time to implement an Oracle client for the WSIT service created on the previous section. The first natural step is to generate the proxy using the Web Service Proxy Wizard included in JDeveloper or the corresponding command-line tool. In order to interface with WCF using MTOM, the client code should set the MTOM_SUPPORT property to "True" either programmatically or using the configuration file. The following code shows a sample client that interacts with the WCF service created in the previous section</P>
<TABLE class="" cellPadding=0 width="100%" border=1>
<TBODY>
<TR>
<TD class="">
<P>public static void Test()<BR>{<BR>try<BR>{<BR>FileTransmitter transmitter= new FileTransmitter();<BR>byte[] buffer= transmitter.GetImg("c:\\temp\\images\\p1.jpg");<BR>FileWSPortClient binding= new FileWSPortClient();<BR>FileWS proxy= binding.getPort();<BR>((OracleStub)proxy)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, service url);<BR><B><I>((OracleStub)proxy)._setProperty(ClientConstants.MTOM_SUPPORT, true);</I></B><BR>int result= proxy.printFileContents(buffer);<BR>System.out.println(result);<BR>}<BR>catch(Exception ex)<BR>{<BR>System.out.println(ex.getMessage());<BR>}<BR>}</P></TD></TR></TBODY></TABLE>
<P><B>&nbsp;</B><B>Messages Messages</B></P>
<P>After hosting the WSIT service in Sun Glassfish and running the Oracle client the following message sequence is produced</P>
<TABLE class="" cellPadding=0 width="100%" border=1>
<TBODY>
<TR>
<TD class="">
<P>POST /MtomServices/FileWSService HTTP/1.1<BR>Host: localhost:8082<BR>Connection: Keep-Alive, TE<BR>TE: trailers, deflate, gzip, compress<BR>User-Agent: Oracle HTTPClient Version 10h<BR>SOAPAction: "PrintFileContents"<BR>Accept-Encoding: gzip, x-gzip, compress, x-compress<BR><B><I>Content-type: multipart/related;type="application/xop+xml";boundary="----=_Part_0_13050435.1185038715262";start="&lt;97b2fe36f9184df3a6fa8792abd9a00c&gt;";start-info="text/xml;charset=UTF-8"</I></B><B><I><BR>Content-length: 12849</I></B><BR><BR>------=_Part_0_13050435.1185038715262<BR>Content-Type: application/xop+xml;charset=UTF-8;type="text/xml;charset=UTF-8"<BR>Content-Transfer-Encoding: 8bit<BR>Content-ID: &lt;97b2fe36f9184df3a6fa8792abd9a00c&gt;<BR><BR>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<BR>&lt;env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://mtomws/"&gt;&lt;env:Body&gt;&lt;ns0:PrintFileContents&gt;&lt;arg0&gt;<B><I>&lt;xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:b9abc481c3664db8b0b7f842d0886c30"/&gt;</I></B>&lt;/arg0&gt;&lt;/ns0:PrintFileContents&gt;&lt;/env:Body&gt;&lt;/env:Envelope&gt;<BR>------=_Part_0_13050435.1185038715262<BR>Content-Type: application/octet-stream<BR>Content-Transfer-Encoding: binary<BR>Content-Id: &lt;b9abc481c3664db8b0b7f842d0886c30&gt;</P></TD></TR></TBODY></TABLE>
<P>&nbsp;<B>SOAP request produced by the Oracle client</B></P>
<TABLE class="" cellPadding=0 width="100%" border=1>
<TBODY>
<TR>
<TD class="">
<P>Content-Id: &lt;rootpart*74f72fe4-510e-48de-a29a-38896f03901d@example.jaxws.sun.com&gt;<BR><B><I>Content-Type: application/xop+xml;charset=utf-8;type="text/xml"</I></B><B><I><BR>Content-Transfer-Encoding: binary</I></B><BR><BR>&lt;?xml version="1.0" ?&gt;&lt;S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;S:Body&gt;&lt;ns2:PrintFileContentsResponse xmlns:ns2="http://mtomws/"&gt;&lt;return&gt;12000&lt;/return&gt;&lt;/ns2:PrintFileContentsResponse&gt;&lt;/S:Body&gt;&lt;/S:Envelope&gt;</P></TD></TR></TBODY></TABLE>
<P><B>SOAP response produced by the Sun WSIT service</B></P>
<P>You can notice that the byte[] in the request message its been optimized using MTOM and XOP. </P>
<P>In the next weeks I will be posting more demos about WS-* protocols interoperability between some of the top Web Services technologies in the market. </P>
<DIV class=postfoot><SPAN class=em>Published</SPAN> Friday, July 27, 2007 9:55 AM by <A href="http://weblogs.asp.net/members/gsusx.aspx">gsusx</A> 
<DIV class=em><SPAN id=ctl00_Main_ctl08_ctl01>Filed under: <A href="http://weblogs.asp.net/gsusx/archive/tags/SOA/default.aspx" rel=tag>SOA</A>, <A href="http://weblogs.asp.net/gsusx/archive/tags/Oracle/default.aspx" rel=tag>Oracle</A>, <A href="http://weblogs.asp.net/gsusx/archive/tags/Web+Services/default.aspx" rel=tag>Web Services</A>, <A href="http://weblogs.asp.net/gsusx/archive/tags/Sun+WSIT/default.aspx" rel=tag>Sun WSIT</A>, <A href="http://weblogs.asp.net/gsusx/archive/tags/J2EE/default.aspx" rel=tag>J2EE</A>, <A href="http://weblogs.asp.net/gsusx/archive/tags/Web+Services+Interoperability/default.aspx" rel=tag>Web Services Interoperability</A></SPAN></DIV></DIV><img src ="http://www.cnblogs.com/huqingyu/aggbug/1216002.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42099/" target="_blank">[新闻]SNS网站风靡影响工作效率 公司下令封杀</a>]]></description></item><item><title>Axis2中使用WS-Addressing协议</title><link>http://www.cnblogs.com/huqingyu/archive/2008/06/08/1215897.html</link><dc:creator>龍龙</dc:creator><author>龍龙</author><pubDate>Sun, 08 Jun 2008 03:00:00 GMT</pubDate><guid>http://www.cnblogs.com/huqingyu/archive/2008/06/08/1215897.html</guid><wfw:comment>http://www.cnblogs.com/huqingyu/comments/1215897.html</wfw:comment><comments>http://www.cnblogs.com/huqingyu/archive/2008/06/08/1215897.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/huqingyu/comments/commentRss/1215897.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/huqingyu/services/trackbacks/1215897.html</trackback:ping><description><![CDATA[&nbsp;作者：清华大学 戴凤军 
<DIV><STRONG><SPAN style="FONT-SIZE: 15pt">WS-Addressing</SPAN></STRONG><STRONG><SPAN style="FONT-SIZE: 15pt">协议</SPAN></STRONG></DIV><PRE style="TEXT-INDENT: 24pt">主要包括三部分内容，一是EndpointReference定义，实际上一个定义了一个服端点的模型。二是<A href="http://www.w3.org/TR/ws-addr-core/#msgaddrprops"><SPAN style="COLOR: windowtext; TEXT-DECORATION: none; text-underline: none">MAP<SPAN style="COLOR: windowtext; TEXT-DECORATION: none; text-underline: none">属性</SPAN></SPAN>的定义，即消息寻址需要设定和支持的相关属性，三是协议的绑定方式，即如何将协议绑定到现有的协议实现之上如WSDL和SOAP。</A></PRE><PRE style="TEXT-INDENT: 24pt">主要用来解决以下问题：一是实现与底层传输的隔离，通过将寻址信息放在SOAP头部从而摆脱了对底层协议寻址的依赖。二是结合实现基于消息的路由，可以根据ReplyTo属性实现基于消息的路由。三是实现有状态的会话，基于MessageID和RelatesTO属性实现对会话状态保存机制，从而提供有状态的服务。</PRE><PRE style="TEXT-INDENT: 24pt">下面基于以上内容对Axis2和CXF关于WS-Addressing的实现情况进行简单的对比</PRE>
<DIV><STRONG><SPAN style="FONT-SIZE: 15pt">一、</SPAN></STRONG><STRONG><SPAN style="FONT-SIZE: 15pt">AXIS2</SPAN></STRONG></DIV>
<DIV><STRONG><SPAN style="FONT-SIZE: 15pt">支持情况：</SPAN></STRONG></DIV>
<DIV><SPAN style="FONT-SIZE: 12pt">支持的版本：submission(2004.8)和final (2005.8)两个版本。</SPAN></DIV>
<DIV>&nbsp;</DIV><PRE style="TEXT-INDENT: 24pt">EndPointReferance在Axis2里是一个核心概念，它通过EndpointReference类型来实现，它所提供的方法完全支持WS-Addressing协议所定义infoset中所有元素的操作。在Axis2中对服务的定位全部是基于EndPointReferance的。</PRE><PRE style="TEXT-INDENT: 24pt">MDP所定义的属性和相应的操作接口都提供了实现。</PRE><PRE style="TEXT-INDENT: 24pt">WSDL addressing-binding在目前版本中没有明确支持，但在一个开发成员的邮件中显示目前已经准备提供支持，但尚无发布相应模块。SOAP -binding在Axis2内核中得到完全的支持。需要明确引入Addresing模块才能处理，事实上仅仅在输入输出流中打开了相关的处理选项。</PRE><PRE>&nbsp;</PRE><PRE><STRONG><SPAN style="FONT-SIZE: 15pt">使用方法：</SPAN></STRONG></PRE><PRE>1．服务端：</PRE><PRE style="TEXT-INDENT: 24pt">在服务端默认情况下Addressing处理是已经嵌入的。加入Addressing需要将Addressing.mar模块放到module目录下，可以有以下几种方式：</PRE><PRE style="TEXT-INDENT: 24pt">一是通过在Axis2.xml配置文件中添加&lt;module ref="addressing"/&gt;，并在相应的管道如in flow和in faultflow中添加AddressingBasedDispatcher即可（注：Axis2中默认已经添加相应内容）</PRE><PRE style="TEXT-INDENT: 24pt">二是在管理控制台Engage相应addressing模块。在axis2.xml 配置文件中添加以下模块引用&lt;module ref="addressing"/&gt;</PRE><PRE>2．客户端：</PRE><PRE style="TEXT-INDENT: 24pt">在客户总端有两种方式加入Addressing处理模块:</PRE><PRE style="TEXT-INDENT: 24pt">一是在程序中显示加入。如下所示：（注意需要将Addressing.mar放到可访问路径下）</PRE><PRE style="TEXT-INDENT: 21pt"><SPAN style="FONT-SIZE: 10.5pt">stub._getServiceClient().engageModule(new</SPAN><SPAN style="FONT-SIZE: 10.5pt">　</SPAN></PRE><PRE style="TEXT-INDENT: 21pt"><SPAN style="FONT-SIZE: 10.5pt">javax.xml.namespace.QName( org.apache.axis2.Constants.MODULE_ADDRESSING ) );</SPAN></PRE><PRE>&nbsp;</PRE><PRE style="TEXT-INDENT: 24pt">二是在axis2.xml 配置文件中添加以下模块引用&lt;m