當你建立WCF Service Library專案時,預設會使用wsHttpBinding,本練習將修改為basicHttpBinding,並透過組態檔設定進階的Binding資訊。
- 組態工具
- 修改預設的wsHttpBinding為basicHttpBinding
- 新增組態設定
- 選basicHttpBinding
- 設SendTimeOut為10分
- 在服務套用binding
- CTRL+S 儲存
- 目前app.config內容如下
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" sendTimeout="00:10:00" />
</basicHttpBinding>
</bindings>
<services>
<service name="WcfServiceLibrary1.Calc">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="WcfServiceLibrary1.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" sendTimeout="00:10:00" />
</basicHttpBinding>
</bindings>
<services>
<service name="WcfServiceLibrary1.Calc">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="WcfServiceLibrary1.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
- F5, Run,可以正確執行運算
沒有留言:
張貼留言