2011-09-16 82 views
1

我的WCF服務[使用basicHttpBinding]託管在IIS 6.Am上,可以在IE瀏覽器的服務URL中使用?wsdl訪問它。這個WCF錯誤的原因是什麼?

我在我的winforms客戶端有一個presenation層,我添加了這個服務的引用,使用VS.Net中的ServiceReferences選項,然後生成一個代理。

當我在這個服務上調用一個方法時,得到這個異常。我在這裏可能會錯過什麼?謝謝。

「值不能爲空。參數名稱uri。」在 System.ServiceModel.Description.ClientViaBehavior..ctor(URI URI)
在System.ServiceModel.Configuration.ClientViaElement.CreateBehavior() 在 System.ServiceModel.Description.ConfigLoader.LoadBehaviors [T](ServiceModelExtensionCollectionElement 1 behaviorElement, KeyedByTypeCollection 1行爲布爾 commonBehaviors)

在 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint,字符串configurationName)

在System.ServiceModel.ChannelFactory.ApplyConfiguration(字符串 configurationName)在 System.ServiceModel.ChannelFactory.InitializeEndpoint(字符串 configurationName,的EndpointAddress地址)在 System.ServiceModel.ChannelFactory 1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait 1.CreateSimplexFactory()在 System.ServiceModel.EndpointTrait 1.CreateChannelFactory() at System.ServiceModel.ClientBase 1.CreateChannelFactoryRef(EndpointTrait 1 endpointTrait) at System.ServiceModel.ClientBase 1.InitializeChannelFactoryRef ()處 TestingClient..ctor(c)中 System.ServiceModel.ClientBase`1..ctor():\演示\服務 參考\ ServiceReference1 \ Reference.cs:線268

這裏是我的配置xm l對於服務器和客戶端:

*服務器:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="ProviderBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" 
       bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="PTSWeb.PriceTestingService" behaviorConfiguration="PTSWeb.Service1Behavior"> 
     <!-- Service Endpoints --> 
     <endpoint address="" binding="basicHttpBinding" contract="PTSWeb.IPriceTesting"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="PTSWeb.Service1Behavior"> 
       <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

*客戶端:

<system.serviceModel> 
    <client> 
     <endpoint address="http://localhost/PTSWeb/PTSWebService.svc" 
     behaviorConfiguration="PTSWeb.Service1Behavior" binding="basicHttpBinding" 
     bindingConfiguration="IPriceTestingBinding" contract="IPriceTesting" 
     name="IPriceTestingPort" /> 
     <endpoint address="https://qaserver/webservice" 
       binding="basicHttpBinding" bindingConfiguration="ProviderBinding" 
       contract="Provider" name="ProviderPort" />  
    </client> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="IPriceTestingBinding" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="None" /> 
     </binding> 
     <binding name="ProviderBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" 
       bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <behaviors> 
     <endpointBehaviors>  
     <behavior name="PTSWeb.Service1Behavior"> 
      <clientVia/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 
+0

請同時顯示ServiceModel配置(客戶端/服務器) – VdesmedT

+0

當然VdesmedT.Have現在添加XML細節我question.Thanks。 – Jimmy

回答

3

在客戶端配置的行爲,你有沒有定義任何的URI ClientVia元素。要麼刪除此行爲,要麼定義via Uri。

這很好解釋clientvia行爲的目的和用途:http://blogs.msdn.com/b/anilkumargupta/archive/2009/05/16/wcf-intermediate-service-between-client-and-server.aspx

+0

是的,當我將我的客戶端xml與使用VS.Net中的AddServiceReference生成的客戶端xml進行比較時,我可以知道這一點。並且stacktrace也指向LoadChannelBehaviors方法。我將行爲節點註釋掉,並從客戶端的端點節點中刪除了它的引用xml.It工作得很好。無論如何感謝VdesmedT的投入。 – Jimmy

相關問題