Rit*_*tha 0 .net c# wcf wcf-binding endpoint
我已经创建了WCF服务,并且Web.Config文件具有以下设置。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" sendTimeout="10:00:00" openTimeout="10:00:00">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Axis.OptimizationService.RMSCalculationService">
<endpoint address="" binding="basicHttpBinding" contract="Axis.RMS.Optimization.Contracts.IRMSCalculationService"></endpoint>
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0"/>
Run Code Online (Sandbox Code Playgroud)
在我的ClassLibrary项目中,我创建了名称为CatpricingService的Servcie参考,并且app.config文件如下所示。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IRMSCalculationService" closeTimeout="00:30:00"
openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="01:00:00"
maxBufferPoolSize="0" maxReceivedMessageSize="2147483647"
useDefaultWebProxy="true" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2200/RMSCalculationService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRMSCalculationService"
contract="CatPricingService.IRMSCalculationService" name="BasicHttpBinding_IRMSCalculationService" />
</client>
Run Code Online (Sandbox Code Playgroud)
我不确定我在做什么错。我做了几次。我不知道是什么错误。对我来说,所有设置似乎都是正确的。我收到此错误。
Could not find default endpoint element that references contract 'CatPricingService.IRMSCalculationService' 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.
Run Code Online (Sandbox Code Playgroud)
我在Stackoverflow上提到了其他问题。谁能弄清楚我的设置出了什么问题?
在这里,我的ClassLibrary项目正在使用外部程序excel.exe运行。(项目属性,“调试”选项卡,选择“启动外部程序”,并赋值为C:\ Program Files \ Microsoft Office \ Office14 \ EXCEL.EXE
谢谢
您需要将配置从移动app.config在你的ClassLibrary项目的app.config主体工程(例如,一个WPF应用程序)。可能是引用您的项目的项目ClassLibrary。
app.config程序执行时仅在主项目中使用。
更新:
在这种情况下,我认为您需要以编程方式创建客户端类,而不要依赖app.config,如下所示:
var binding = new BasicHttpBinding();
var endPointAddress = new EndpointAddress("http://localhost:2200/RMSCalculationService.svc");
var client = new YourGeneratedClientClass(binding, endPointAddress);
Run Code Online (Sandbox Code Playgroud)