现有的 Asp.Net 项目正在使用 WCF WebService。工作正常。
我决定将业务逻辑移到类库中。所以现在类库使用 WCF Web 服务,而 Asp.net 应用程序没有引用它。
在 Asp.net Web 应用程序(调试)第一次调用类库时,我收到一个错误:
在 ServiceModel 客户端配置部分中找不到引用合同“CouponParking.ICouponService”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
我盯着类库 app.config(当我第一次添加对 WCF 服务的服务引用时由 IDE 创建),它看起来不错。
假设它需要改变,请有人批评它并告诉我需要做什么。我对端点的理解是初步的。
asp.net web.config 确实有一个空的 servicemodel 部分。我认为这是正确的,因为服务引用已被删除。
类库 app.config 紧随其后的是 WCF web.config,因此您可以看到另一端。
WCF 有一个额外的 JSON 端点,因为它也被 Android 设备使用。
应用程序配置:
<?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>
网络配置:
<?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>