WCF大數據傳輸2

第四步:配置WCF服務
在Services項目中右擊“App.Config”配置文件,在彈出的右鍵菜單中選擇“編輯WCF配置”。
單擊左側的“服務”-“Wcf_MassData.DataTransfers”在右側的Name,彈出“服務類型瀏覽器”對話框,在此類型中我們找到此WCF服務項目編譯出來的Wcf_MassData.dll文件,雙擊它就可以出現此服務中的對外公佈的服務,點擊選中它單擊確定。
這樣我們就可以把對外公司的服務改變爲我們剛編寫的服務了。
然後,我們展開左側“服務”->“Wcf_MassData.DataTransfers”->“終結點”,單擊第一個“空名稱”,從右邊的“終結點屬性”中的Contract中我們可以看到,這裏的Contract仍然用的是Services.IService1。
那我們按照上面的做法,找到此WCF服務項目編譯出來的Wcf_MassData.dll,雙擊它找到裏面對應的ServiceContract點擊確定就可以了。

點擊菜單“文件”-“保存”就可以把我們對App.Config的修改保存回配置文件了。
OK,現在我們對WCF的配置算是完成了。
App.Config代碼:
<?xml version="1.0" encoding="utf-8" ?>
<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>
        <services>
            <service name="Wcf_MassData.DataTransfers">
                <endpoint address="" binding="wsHttpBinding" contract="Wcf_MassData.IDataTransfers">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration=""
                    contract="Wcf_MassData.IDataTransfers" />
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8732/Design_Time_Addresses/Wcf_MassData/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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章