| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2009年2月12日 星期四
2009 年 2 月安全性公告發行
Binding (2): netTcpBinding
netTcpBinding
<netTcpBinding> <binding closeTimeout="TimeSpan" hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard" listenBacklog="Integer" maxBufferPoolSize="integer" maxBufferSize="Integer" maxConnections="Integer" maxReceivedMessageSize="Integer" name="string" openTimeout="TimeSpan" portSharingEnabled="Boolean" receiveTimeout="TimeSpan" sendTimeout="TimeSpan" transactionFlow="Boolean" transactionProtocol="OleTransactions/WSAtomicTransactionOctober2004" transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse" <reliableSession ordered="Boolean" inactivityTimeout="TimeSpan" enabled="Boolean" /> <security mode="None/Transport/Message/Both"> <message clientCredentialType="None/Windows/UserName/Certificate/CardSpace" defaultProtectionLevel="None/Sign/EncryptAndSign" algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15" /> <transport clientCredentialType="None/Windows/Certificate" protectionLevel="None/Sign/EncryptAndSign" /> </security> <readerQuotas maxDepth="integer" maxStringContentLength="integer" maxByteArrayContentLength="integer" maxBytesPerRead="integer" maxNameTableCharCount="integer" /> </binding> </netTcpBinding>
- 當Client 是在 intranet 環境時,使用 netTcpBinding 是一個對效能最好的選擇,而且可以host 在 Windows Service 上。IIS5 或 IIS6 只能使用 HttpBinding。IIS7 則可以使用 WAS 方式來支援 netTcpBinding。
- netTcpBinding 使用 TCP protocol 並且完全支援 SOAP security, transactions, 與 reliability。
- 由於此 netTcpBinding 支援 .net 平台,因此並不適合跨平台如.NET + JAVA。我認為此將取代原本的 .net Remoting.
- 使用三個 binding elements. 第一個是 BinaryMessageEncodingBindingElement ,負責將訊息轉換成將來傳輸用的二進位格式。
- 第二個是TransactionFlowBindingElement ,只有一個 TransactionProtocol 屬性,定義交易(transactions) 如何從 clinet 流向 service。預設值是 TransactionProtocol.OleTransactions, 意思就是不支援 WS-AtomicTransaction。如果要支援 WS-AtomicTransaction,就設成 TransactionProtocol.WSAtomicTransaction11 或 TransactionProtocol.WSAtomicTransactionOctober2004。注意到需要使用 WS-AtomicTransaction 組態公用程式 (wsatConfig.exe) 來設定該台伺服器。
- 第三個是 TcpTransportBindingElement, 負責傳輸的工作。
97資訊委外服務人員計價參考要點
參考自 中華民國資訊軟體協會
1. 專案管理類的金額下降了
2. 系統分析、資料庫管理、資訊安全管理、系統整合、品質保證 類金額提昇了
3. 系統管理類的金額下降了
可見得之前專案管理在台灣大熱門,但到後來,國內仍然以實務為主。
第 一 類 系 統
| 計費類別 | 95 | 96 | 97 |
| 職 別 | |||
| 主 管 專案經理 專案負責人 計畫主持人 | 199,836 | 229,320 | 199,836 |
| 專案管理 | 173,628 | 170,352 | 160,524 |
| 系統分析 資料庫管理 資訊安全管理 系統整合 品質保證 | 157,248 | 170,352 | 167,076 |
| 程式設計 | 134,316 | 134,316 | 137,592 |
| 系統管理 | 140,868 | 121,212 | 117,936 |
| 機器操作 網頁設計 客戶服務 | 104,832 | 111,384 | 104,832 |
2009年2月11日 星期三
Binding (1) : BasicHttpBinding
WCF 中,最複雜的,我認為應該是 Binding 了。
要選擇適當的 binding, 通常要了解一堆的 WS-* 的標準,配合客戶需求,剔除不必要的選項後,才是我們適合的 binding.
那什麼是 Binding 呢?
Binding 定義了客戶端與伺服器端的「溝通方式」,主要有下列三大類(但不限)
- Transport Protocol: Http, Tcp, Msmq, etc
- Message format: Xml, Mtom, Json, binary, etc
- Message protocols: Soap, WS-*, none, etc
WCF 內建提供的 Binding, 目前已達12 種了。如果都不適用,還可以自訂 CustomBinding。
那要如何選擇呢?有沒一個建議的流程呢?在 patterns & practices Improving Web Services Security Guide 中有簡略描述。以下就嘗試翻譯並整理一下!
<basicHttpBinding>
<binding
allowCookies="Boolean"
bypassProxyOnLocal="Boolean"
closeTimeout="TimeSpan"
envelopeVersion="None/Soap11/Soap12"
hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard"
maxBufferPoolSize="Integer"
maxBufferSize="Integer"
maxReceivedMessageSize="Integer"
messageEncoding="Text/Mtom"
name="string"
openTimeout="TimeSpan"
proxyAddress="URI"
receiveTimeout="TimeSpan"
sendTimeout="TimeSpan"
textEncoding="UnicodeFffeTextEncoding/Utf16TextEncoding/Utf8TextEncoding"
transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse"
useDefaultWebProxy="Boolean"
<security mode="None/Transport/Message/TransportWithMessageCredential/TransportCredentialOnly">
<transport clientCredentialType="None/Basic/Digest/Ntlm/Windows/Certificate"
proxyCredentialType="None/Basic/Digest/Ntlm/Windows"
realm="string" />
<message
algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
clientCredentialType="UserName/Certificate"/>
</security>
<readerQuotas maxDepth="Integer"
maxStringContentLength="Integer"
maxByteArrayContentLength="Integer"
maxBytesPerRead="Integer"
maxNameTableCharCount="Integer" />
</binding>
</basicHttpBinding>
basicHttpBinding
- 與 ASMX web service 相容,即WS-I Basic Profile 1.1
- 預設沒有實作安全相關標準。如果需要安全,則需要設定 Security.Mode。
- 在沒有安全性的要求下,(即 <scurity mode=’none’> 或 Security.Mode 設為 BasicHttpSecurityMode.None),basicHttpBinging使用了 TextMessageEncodingBindingElement 與 HttpTransportBindingElement 這兩個 binding element。TextMessageEncodingBindingElement 將訊息格式化為與 SOAP 相容。HttpTransportBindingElement 則將訊息以 http protocol 傳送。因此,在basicHttpBinding 中,可以看到TextMessageEncodingBindingElement 與 HttpTransportBindingElement 相關的 configuration schema.
- 若要使用 SSL, 即要以 HTTPS 來傳送訊息,則需設定<scurity mode=’Transport’>,此時 HttpTransportBindingElement會被 HttpsTransportBindingElement 所取代。事實上HttpsTransportBindingElement 繼承HttpTransportBindingElement,所以只有多了一些功能。
- BasicHttpBinding 可以使用於 IIS5 或 IIS6 上
- messageEncoding=”Mtom” 時,會將 TextMessageEncodingBindingElement 以 MtomMessageEncodingBindingElement 取代。MTOM 編碼方式 實作了 W3C SOAP Message Transmission Optimization Mechanism, 用於以SOAP格式傳輸 binary 資料如附件、圖片,以降低訊息的大小。
2009年2月10日 星期二
2009年2月9日 星期一
WCF: 使用 Header 傳遞訊息
在使用 WCF 時,自訂訊息內容自然是免不了的設計。因此使用 DataContract, 已經是 WCF 中經典中的經典了。
如果需要 WCF client 多傳一些訊息回來,就必須在Service上更改 DataContract, 然後Client 再更新程式…..
等一下,DataContract 是一個 Contract,怎麼能說改就改?
話又說回來,面對各式各樣的客戶,常常見到不同的需求需要傳遞不同的訊息。此時該怎麼辦?
原來,WCF 內建有個傳遞訊息的方法,且不需要修改 DataContract。
步驟1:修改 WCF Client 的 config。
<client> <endpoint address="http://localhost:8081/test/service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" > <!-- use header to pass message --> <headers> <MyHeader xmlns="http://sample.org/test"> This is my test data </MyHeader> </headers> </endpoint> </client>
步驟2: 修改 Service, 使用 OperationContext 讀取 header
int myHeaderIndex = OperationContext.Current.RequestContext.RequestMessage.Headers.FindHeader("MyHeader", "http://sample.org/test");
string result;
if (myHeaderIndex != -1)
{
result = OperationContext.Current.RequestContext.RequestMessage.Headers.GetHeader(myHeaderIndex);
}
else
result = OperationContext.Current.RequestContext.RequestMessage.Headers.Action;
return string.Format("You entered: {0}, Header: {1}", value, result);
需要注意的是, Client config 中,可以傳不同的訊息,由 Service 來搜尋header。這樣一來,就不需要修改 DataContract 了。
當然,這樣也是有相當大的壞處,這樣會造成設計人員各自傳遞不同格式的訊息。假以時日,一堆不同的自訂訊息,最終難以維護。
2009年2月5日 星期四
Enterprist Library: 寫到同一個 log file
也是寫 log 的問題。
當 log application block (LAB) 和 exception handling application block (EHAB) 寫訊息到同一個檔案時,會因 file 已被 open 的關係,產生一個 (GUID)log.log 類似的檔案。
這一點很不好,因為我想將所有的訊息(記錄訊息和錯誤訊息)同到相同的檔案,以方便觀察程式的實際運作行為。
原來這一點,已在 V4.0 版被修正了.
在 EHAB 的 logging handler 上,取得 property
property 上,有個新的 UseDefaultLogger,預設值為 false, 將它改為 True。就完成了。


