2013-10-22 46 views
0

我寫一個WCF應用程序使用POST從Android的接受一個文件,它拋出一個異常System.ServiceModel.ServiceActivation,我明白了什麼是從完成從鏈接: -如何將綁定添加到WCF的Config文件?

System.ServiceModel.ServiceActivationException in wcf service

以下是Web.config文件

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="Service1Behavior"> 
        <serviceMetadata httpGetEnabled="true"/> 
        <serviceDebug includeExceptionDetailInFaults="false"/> 

       </behavior> 
      </serviceBehaviors> 
      <endpointBehaviors> 
       <behavior name="web"> 
        <webHttp/> 
       </behavior> 
      </endpointBehaviors> 
     </behaviors> 

     <services> 
      <service name="WcfImageUpload.Service1" 
        behaviorConfiguration="ServiceBehaviour" > 
       <host> 
        <baseAddresses> 
         <add baseAddress="http://somesite.com:5555/Service1/" /> 
        </baseAddresses> 
       </host> 
       <endpoint name="Service1" 
          address="" 
          binding="webHttpBinding" 
          contract="WcfImageUpload.IService1" 
          behaviorConfiguration="web"/> 

       <endpoint name="LoginServiceMex" 
          address="mex" 
          binding="mexHttpBinding" 
          contract="IMetadataExchange" /> 
      </service> 
     </services> 
    </system.serviceModel> 
</configuration> 

我需要添加綁定

<bindings> 
    <webHttpBinding> 
    <binding name="WebHttpEndpointBinding"> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows"/> 
     </security> 
    </binding> 
    </webHttpBinding> 
</bindings> 

我應該在哪裏添加,我是.NET和WCF中的新手。

+0

嘗試鏈接http://msdn.microsoft.com/en-us/library/ms733932.aspx – kaushik0033

+0

將它添加到你的配置中,** **之後** **'元素 –

+0

的目的是什麼? – Sreekanth

回答

0

你可以把像下面....

<system.serviceModel> 
    <services> 
    <service name="MyService"> 
    <endpoint address="http://localhost/IISHostedService/MyService.svc" 
    binding="wsHttpBinding" bindingName="wshttpbind" contract="IMyService"> 
    <identity> 
    <dns value="localhost"/> 
    </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
    </services> 
    <bindings> 
     <webHttpBinding> 
     <binding name="WebHttpEndpointBinding"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows"/> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 

</system.serviceModel> 

謝謝 維沙爾帕特爾

0

您需要在的web.config中的結合WCF服務在<system.ServiceModel>標籤內。

你必須通過WCF支持多個綁定,如基本的HTTP綁定,網站HttpBinding,等的wsHttpBinding

如果你要訪問像ASMX服務的服務,使用其basicHttpBinding的使用SOAP。

如果您希望您的WCF是RESTful,那麼請使用WebHttpBinding並相應地配置行爲。還有其他的綁定,比如wsHttpBindlings更安全。

相關問題