現有的Asp.Net項目正在使用WCF WebService。 工作正常。訪問WCF的ASP.Net類庫項目
我決定將業務邏輯轉移到類庫中。所以,現在類庫使用WCF Web服務,Asp.net應用程序沒有引用它。
第一次調用到由Asp.net Web應用程序(調試)類庫我得到一個錯誤:
Could not find default endpoint element that references contract 'CouponParking.ICouponService' 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.
我已經在類庫的app.config(這是由創建盯着IDE,當我第一次添加一個服務引用到WCF服務),它對我來說看起來沒問題。
假設需要改變,有人可能會批評它,並告訴我需要做什麼。我對端點的理解是基本的。
asp.net web.config確實有一個空的servicemodel部分。我認爲這是正確的,因爲服務參考已被刪除。
類庫app.config接着是WCF web.config,所以你可以看到另一端。
WCF有一個額外的JSON端點,因爲它也被Android設備使用。
App.Config中:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SoapEndPoint" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8707/CouponParking.svc/SOAP"
binding="basicHttpBinding" bindingConfiguration="SoapEndPoint"
contract="CouponParking.ICouponService" name="SoapEndPoint" />
</client>
</system.serviceModel>
</configuration>
的Web.Config:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxx" >
<section name="CouponParkingWCF.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" />
</basicHttpBinding>
<webHttpBinding>
<binding name="JsonBinding" />
</webHttpBinding>
</bindings>
<services>
<service name="CouponParkingWCF.CouponService">
<endpoint name ="SoapEndPoint"
address="SOAP"
binding="basicHttpBinding"
contract="CouponParkingWCF.ICouponService" />
<endpoint name="JSON"
address="REST" behaviorConfiguration="JsonBehavior" binding="webHttpBinding"
contract="CouponParkingWCF.ICouponService" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
<applicationSettings>
<CouponParkingWCF.Properties.Settings>
<setting name="ServerIp" serializeAs="String">
<value>192.168.0.224</value>
</setting>
<setting name="Database" serializeAs="String">
<value>WgtnTickTrakTest</value>
</setting>
</CouponParkingWCF.Properties.Settings>
</applicationSettings>
</configuration>
謝謝,現在有道理。在Asp.net仍然有服務參考時完成初始測試。只在最後刪除它。 –
這真的節省了我的時間,謝謝 – DEBAL