2010年9月6日 星期一

WCF 3.5/4.0 REST 設定(WCF REST Service Template)

1.在你的 SVC 檔案加上 Factory="System.ServiceModel.Activation.WebServiceHostFactory"
2.修改 Web.config 將 這個 node 內跟這個 Service 有關的全部刪除
3.如果安裝在IIS 6 還要做以下的動作(做完要IIS_RESET 才會生效)
On IIS configuration of extensions mappings, edit the .svc mapping and remove the "Check that file exists" checkbox. that should do the magic. If you get Authentication errors, make sure the IIS site is not configured to allow windows integrated security, only anonymous access.
4.如果你用的是 WCF REST Service Template 開發出來的專案,因為沒有 .SVC 檔,如果HOST在IIS 6,還需要額外設定  Installing Wildcard Application Mappings (IIS 6.0)
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true

http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/
5.如果 遇到 The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access 的錯誤可以重新註冊 ASP.NET ex: aspnet_regiis -ir

如此就可以用 REST 的方式來存取 Web Service

請參考
http://beyondrelational.com/blogs/dhananjaykumar/archive/2010/08/11/webservicehost-hosting-a-wcf-rest-service.aspx


http://dhananjaykumar.net/2010/04/27/picture-gallery-for-windows-7-phone-using-wcf-rest-service/






2010年8月25日 星期三

WCF .svc 部屬在 IIS 6 會發生 404 File not found

1.最簡單的解法是安裝 .net framework 4.0 ,然後將 IIS Application Asp.net版本改成 4.0

2.手動註冊方法如下

More than likely .svc extension is not registered under IIS as being handled by
ASP.NET(WCF)

Try these 2 steps (replace Framework with Framework64 if it's needed):

Go to:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\
and then run:
aspnet_regiis -i

Go to:
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
and then run:
ServiceModelReg.exe -i

2010年7月7日 星期三

程式匯出資料成為CSV時,如何保留完整的數字如 0953

EXCEL 開啟CSV檔案時會自動判斷欄位的內容是文字還是數字,只是這樣的行為有時會造成困擾,如電話,訂單編號,銀行代碼,只要前面是0開頭的,0都會不見,解決方法是輸出資料時用以下的格式

="資料內容"

ex: ="0015"

這樣EXCEL就會真實的顯示0015,而不是顯示15

2010年5月20日 星期四

iSeries Access for Windows DataQueue Return Code

6000    CWBDQ_INVALID_ATTRIBUTE_HANDLE
Invalid attributes handle.
6001 CWBDQ_INVALID_DATA_HANDLE
Invalid data handle.
6002 CWBDQ_INVALID_QUEUE_HANDLE
Invalid queue handle.
6003 CWBDQ_INVALID_READ_HANDLE
Invalid data queue read handle.
6004 CWBDQ_INVALID_QUEUE_LENGTH
Invalid maximum record length for a data queue.
6005 CWBDQ_INVALID_KEY_LENGTH
Invalid key length.
6006 CWBDQ_INVALID_ORDER
Invalid queue order.
6007 CWBDQ_INVALID_AUTHORITY
Invalid queue authority.
6008 CWBDQ_INVALID_QUEUE_TITLE
Queue title (description) is too long or cannot be converted.
6009 CWBDQ_BAD_QUEUE_NAME
Queue name is too long or cannot be converted.
6010 CWBDQ_BAD_LIBRARY_NAME
Library name is too long or cannot be converted.
6011 CWBDQ_BAD_SYSTEM_NAME
System name is too long or cannot be converted.
6012 CWBDQ_BAD_KEY_LENGTH
Length of key is not correct for this data queue or key length is
greater than 0 for a LIFO or FIFO data queue.
6013 CWBDQ_BAD_DATA_LENGTH
Length of data is not correct for this data queue. Either the data
length is zero or it is greater than the maximum allowed of
31744 bytes (64512 bytes for V4R5 and later versions of i5/OS).
Note: The maximum allowed data lengh when
connected to i5/OS V4R5MO and later systems has been increased
to 64512 bytes. When connected to earlier releases of i5/OS,
64512 bytes of data may be written to a data queue, but the
maximum length of data that may be read from a data queue
is 31744 bytes.
6014 CWBDQ_INVALID_TIME
Wait time is not correct.
6015 CWBDQ_INVALID_SEARCH
Search order is not correct.
6016 CWBDQ_DATA_TRUNCATED
Returned data was truncated.
6017 CWBDQ_TIMED_OUT
Wait time has expired and no data has been returned.
6018 CWBDQ_REJECTED_USER_EXIT
Command rejected by user exit program.
6019 CWBDQ_USER_EXIT_ERROR
Error in user exit program or invalid number of exit programs.
6020 CWBDQ_LIBRARY_NOT_FOUND
Library not found on system.
6021 CWBDQ_QUEUE_NOT_FOUND
Queue not found on system.
6022 CWBDQ_NO_AUTHORITY
No authority to library or data queue.
6023 CWBDQ_DAMAGED_QUEUE
Data queue is in an unusable state.
6024 CWBDQ_QUEUE_EXISTS
Data queue already exists.
6025 CWBDQ_INVALID_MESSAGE_LENGTH
Invalid message length - exceeds queue maximum record length.
6026 CWBDQ_QUEUE_DESTROYED
Queue destroyed while waiting to read or peek a record.
6027 CWBDQ_NO_DATA
No data was received.
6028 CWBDQ_CANNOT_CONVERT
Data cannot be converted for this data queue. The data queue
can be used but data cannot be converted between ASCII and EBCDIC.
The convert flag on the data object will be ignored.
6029 CWBDQ_QUEUE_SYNTAX
Syntax of the data queue name is incorrect. Queue name must follow
system object syntax. First character must be alphabetic and all
following characters alphanumeric.
6030 CWBDQ_LIBRARY_SYNTAX
Syntax of the library name is incorrect. Library name must follow
system object syntax. First character must be alphabetic and all
following characters alphanumeric.
6031 CWBDQ_ADDRESS_NOT_SET
Address not set. The data object was not set with cwbDQ_SetDataAddr(),
so the address cannot be retrieved. Use cwbDQ_GetData() instead of
cwbDQ_GetDataAddr().
6032 CWBDQ_HOST_ERROR
Host error occurred for which no return code is defined. See the
error handle for the message text.
6033 CWBDQ_INVALID_SYSTEM_HANDLE
System handle is invalid.
6099 CWBDQ_UNEXPECTED_ERROR
Unexpected error.