2013-07-03 151 views
1

我收到的物理WSDL文件在我的C# Windows服務項目中使用。無法撥打網絡服務

我更換項目文件夾內的文件,並從「添加服務引用」添加

它被添加到項目&我成功地創建客戶端對象,並調用它的類 但是當我運行的服務下面的錯誤提出

Could not find default endpoint element that references contract 'ABRECONService.ServiceIF' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. 
    at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) 
    at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration) 
    at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName) 
    at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) 
    at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) 
    at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory() 
    at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait) 
    at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef() 
    at System.ServiceModel.ClientBase`1..ctor() 
    at sample.eZeePayService.DateExchangeServiceIFClient..ctor() in C:\Users\Hani\Documents\Visual Studio 2010\Projects\sample\sample\Service References\ABRECONService\Reference.cs:line 32 
    at sample.ABRECONHandler.ABRECONCaller(String message) in C:\Users\Hani\Documents\Visual Studio 2010\Projects\sample\sample\ABRECONHandler.cs:line 15 

,並在app.config是

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    </configSections> 
    <appSettings> 
    </appSettings> 
    <system.net> 
    <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy> 
    </system.net> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="ServiceIFBinding" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
        useDefaultWebProxy="true"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <security mode="None"> 
         <transport clientCredentialType="None" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="UserName" algorithmSuite="Default" /> 
        </security> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="ABRECON.MainBehavior"> 
        <serviceMetadata httpGetEnabled="true"/> 
        <serviceDebug includeExceptionDetailInFaults="false"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <services> 
      <service behaviorConfiguration="ABRECON.MainBehavior" name="ABRECON.Main"> 
       <endpoint address="" binding="wsHttpBinding" contract="ABRECON.IMain"> 
        <identity> 
         <dns value="localhost"/> 
        </identity> 
       </endpoint> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
       <host> 
        <baseAddresses> 
         <add baseAddress="http://localhost:8732/Design_Time_Addresses/ABRECON/Main/"/> 
        </baseAddresses> 
       </host> 
      </service> 
     </services> 
    </system.serviceModel> 
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup> 
</configuration> 

指出的是,網絡SERV冰提供商是在不同的局域網上 我錯過了什麼? 請指導urgenlt

回答

1

僅僅從WSDL文件創建服務類是不夠的。您需要將信息添加到客戶的配置文件(app.config)中,以指示如何訪問該服務。


而不是創建從給定的WSDL文件服務的參考,你可以嘗試直接指向服務引用對話框http://localhost:8732/Design_Time_Addresses/ABRECON/Main/(MEX的配置文件的地址)。確保服務正在運行。

如果一切正常,這會將相應的配置條目自動添加到您的app.config

0

是的,正如你所說的基地址是指向其他局域網中的地址,這是你無法連接到它的原因。