0
我是WCF新手,正在開發一個項目 ,我正在構建一個Web項目(ASP.NET 2.03.5/C#),名爲 的WCF庫。從Web項目調用服務Lbrary - 什麼在Web.Config?
我在這裏有幾件事情。
1)我爲我的JSON Web方法爲我的 SOAP合同(ISOAP)提供了一個恭維合同(IJSON)。 2)我有一個合同,IFileTransferService,處理 文件流。
能否請你看看我的app.config和WEB.CONFIG 文件,並告訴我,如果他們看起來是正確的,或者如果我再生 認爲這是在我的App.Config中在我的web.config不必要的? 如果我使用服務庫,我真的需要做兩次事情(聲明服務,綁定等)嗎?這看起來是 對不對?
此外,任何其他文體/建設性意見有關 什麼我一邊system.serviceModel總是讚賞。
謝謝你的時間。
WEB.CONFIG
<system.serviceModel>
<client>
<endpoint name="MySOAPAuthEP"
address="http://localhost:1241/WebProj/auth.svc/soap"
binding="basicHttpBinding"
bindingConfiguration="soapWeb"
contract="Project.WebAPI.Authentication.ISOAPAuthService" />
<endpoint name="MySOAPTradeEP"
address="http://localhost:1241/WebProj/trade.svc/soap"
binding="basicHttpBinding"
bindingConfiguration="soapWeb"
contract="Project.WebAPI.Trade.ISOAPTradeService" />
<endpoint name="MySOAPFileTransferEP"
address="http://localhost:1241/WebProj/filetransfer.svc/soap"
binding="basicHttpBinding"
bindingConfiguration="httpLargeDataStream"
contract="Project.WebAPI.FileTransfer.ISOAPFileTransferService" />
<endpoint name="MyJSONAuthEP"
binding="webHttpBinding"
bindingConfiguration="jsonWeb"
contract="Project.WebAPI.Authentication.IJSONAuthService" />
<endpoint name="MyJSONTradeEP"
binding="webHttpBinding"
bindingConfiguration="jsonWeb"
contract="Project.WebAPI.Trade.IJSONTradeService" />
<endpoint name="MyJSONFileTransferEP"
binding="webHttpBinding"
bindingConfiguration="jsonWeb"
contract="Project.WebAPI.FileTransfer.IJSONFileTransferService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="soapWeb" />
<binding name="httpLargeDataStream" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferSize="65536"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom" transferMode="Streamed">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="jsonWeb" maxBufferSize="1500000" maxBufferPoolSize="1500000"
maxReceivedMessageSize="1500000">
<readerQuotas maxDepth="32" maxStringContentLength="656000" maxArrayLength="656000"
maxBytesPerRead="656000" maxNameTableCharCount="656000" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="WebHttpEPBehavior">
<webHttp />
</behavior>
<behavior name="BasicHttpEPBehavior" />
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="Default" name="Project.WebAPI.Trade.TradeService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" name="MyJSONTradeEP" contract="Project.WebAPI.Trade.IJSONTradeService" />
<endpoint address="soap" binding="basicHttpBinding" name="MySOAPTradeEP"
contract="Project.WebAPI.Trade.ISOAPTradeService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1243/WebProj/trade.svc" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="Default" name="Project.WebAPI.Authentication.AuthService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" name="MyJSONAuthEP" contract="Project.WebAPI.Authentication.IJSONAuthService" />
<endpoint address="soap" binding="basicHttpBinding" name="MySOAPAuthEP"
contract="Project.WebAPI.Authentication.ISOAPAuthService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1242/WebProj/auth.svc" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="Default" name="Project.WebAPI.FileTransfer.FileTransferService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" name="MyJSONFileTransferEP" contract="Project.WebAPI.FileTransfer.IJSONFileTransferService" />
<endpoint address="soap"
binding="basicHttpBinding"
name="MySOAPFileTransferEP"
bindingConfiguration="httpLargeDataStream"
contract="Project.WebAPI.FileTransfer.ISOAPFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1244/WebProj/filetransfer.svc" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
的app.config
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="soapWeb" />
<binding name="httpLargeDataStream"
maxReceivedMessageSize="2147483647"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transferMode="Streamed"
messageEncoding="Mtom"
maxBufferSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="jsonWeb" maxBufferSize="1500000" maxBufferPoolSize="1500000"
maxReceivedMessageSize="1500000">
<readerQuotas maxDepth="32" maxStringContentLength="656000" maxArrayLength="656000"
maxBytesPerRead="656000" maxNameTableCharCount="656000" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Default" name="Project.WebAPI.Trade.TradeService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" name="MyJSONTradeEP" contract="Project.WebAPI.Trade.IJSONTradeService" />
<endpoint address="soap" binding="basicHttpBinding" name="MySOAPTradeEP"
contract="Project.WebAPI.Trade.ISOAPTradeService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1243/WebProj/trade.svc" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="Default" name="Project.WebAPI.Authentication.AuthService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" name="MyJSONAuthEP" contract="Project.WebAPI.Authentication.IJSONAuthService" />
<endpoint address="soap" binding="basicHttpBinding" name="MySOAPAuthEP"
contract="Project.WebAPI.Authentication.ISOAPAuthService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1242/WebProj/auth.svc" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="Default" name="Project.WebAPI.FileTransfer.FileTransferService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" name="MyJSONFileTransferEP" contract="Project.WebAPI.FileTransfer.IJSONFileTransferService" />
<endpoint address="soap" binding="basicHttpBinding" name="MySOAPFileTransferEP"
contract="Project.WebAPI.FileTransfer.ISOAPFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1244/WebProj/filetransfer.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebHttpEPBehavior">
<webHttp />
</behavior>
<behavior name="BasicHttpEPBehavior" />
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
謝謝Marc。我遵循你的建議,只是離開部分在我的web.config,但現在似乎無法讓它運行。我收到以下錯誤:服務'AuthService'具有零應用程序(非基礎設施)端點。這可能是因爲沒有爲您的應用程序找到配置文件,或者因爲在配置文件中找不到匹配服務名稱的服務元素,或者因爲服務元素中沒有定義端點。我記得當我開始並通過在Web.config中轉儲服務和綁定來解決它時,我遇到了這個錯誤。想法?再次感謝。 –
2009-10-26 07:10:34
你在哪裏舉辦你的服務課程? IIS?然後,您需要在訪問該服務的客戶端app.config中的web.config和您的''(但不包括「services」) –
2009-10-26 08:40:52
再次感謝。不,我現在正在自主發展。 – 2009-10-26 15:13:49