Wednesday, December 10, 2008

在Https中建立WCF service

在web.config中設定相關字串

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IWGWCF" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>

<services>
<service behaviorConfiguration="ServiceBehavior" name="WGWCF">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWGWCF"
name="serverEnd" contract="IWGWCF" />
<host>
<baseAddresses>
<add baseAddress="https://17-00sf300-01/WGWS" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>

<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"
httpsGetUrl="https://17-00sf300-01/WGWS/" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="WGWCFBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"
httpsGetUrl="https://17-00sf300-01/WGWS/" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

WGWCF 使用session

在binding中設定好ReliableSession.enabled = True即可

 

另外在Contract中,可以設定SessionMode=SessionMode.Requied

[ServiceContract(Name = "IWGWCF", SessionMode = SessionMode.Required)]
public interface IWGWCF
{
[OperationContract]
string search(string keyword, int start, int returnCount);


}

在behavior中可以設定session使用的時間周期

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class WGWCF : IWGWCF
{
public string search(){

}
}

Tuesday, December 2, 2008

加入服務參考

有別於'加入WEB參考',WCF所提供的服務需要透過'加入服務參考'來讓client使用。

在開發client程式中,使用vs 2008升級了原本的舊程式碼,卻怎麼也找不到'加入服務參考'。由於轉換的時候把專案轉成了'網站'形式,以為是因為網站無法使用'服務參考'。

在這篇文章中有說明 http://msdn.microsoft.com/zh-tw/library/bb398791.aspx (......"只有以 .NET Framework 3.5 為目標的網站和以 .NET Framework 3.0 或 .NET Framework 3.5 為目標的 Web 應用程式專案,才有 [加入服務參考] 對話方塊。"........... )

現在可以使用wcf的服務了。

EXT的data store

使用data store時,想要動態改變其中的變數。會使用到data store的Properties--baseParams。

剛開始沒看懂以為這個param指的是data store中所有的變數都可以動態改變,因此有了這樣的程式碼(原先已經generate好一個data store了,現在是要改變裡面的proxy屬性)

Ext.apply(Paging.grid.store.baseParams,
{
proxy: new Ext.data.HttpProxy({
url: 'http://aaa.com.tw/aaa.aspx?start=ooo&end=xxx'
})
start: 0,
limit: 3,
}
);


想要動態改變proxy中的url屬性。但是一直無法替換,一直到大師提醒才發現baseParams指的是url中可以傳遞的參數,所以改變如下

Ext.apply(Paging.grid.store.baseParams,
{
start: 0,
limit: 3,
start: cal_1_input,
end: cal_2_input
}
);


這樣可以動態的改變原本data store中的內容了