我有RESTFUL WCF,web.config看起来像
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="ServiceSoap" 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="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="basicHttpBindingConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="None" />
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
<binding name="basicHttpBindingConfig2" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="None" />
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
<binding name="secureBasicHttpBindingConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="Transport" />
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name ="servicebehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restbehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Schools.WebService.SchoolsWebService" behaviorConfiguration ="servicebehavior">
<endpoint name="SOAPEndPoint" binding="basicHttpBinding" contract="Schools.WebService.ISchoolsWebService" address ="soap"/>
<endpoint name="RESTEndPoint" binding="webHttpBinding" contract="Schools.WebService.ISchoolsWebService" address ="rest" behaviorConfiguration ="restbehavior"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
</system.serviceModel>
但是在创建webrefrence时使用(SOAP)
_tempClient = new ArabicEWorldWebServiceClient("SOAPEndPoint");
我收到了错误:
无法找到名称为&#39; SOAPEndPoint&#39;的端点元素和合同&#39; SchoolsWebServiceClientInstance.ISchoolsWebService&#39;在ServiceModel客户端配置部分中。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。
答案 0 :(得分:0)
我认为您缺少客户端配置或者可能是错误的。您刚刚发布了服务配置。在客户端,您还需要配置端点以便能够为您的服务打开通道。客户端端点在<client>
<system.serviceModel>
标记内定义
有关客户端配置的详细信息,请参阅here。
您的客户端配置可能看起来像这样:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!--This is only an example. Make sure your binding configuration regarding security and other matters, matches your service.-->
<binding name="httpBindingConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint
name="SOAPEndPoint"
address="http://localhost/SOAP"
binding="basicHttpBinding"
bindingConfiguration="httpBindingConfig"
contract="Schools.WebService.ISchoolsWebService" />
</client>
</system.serviceModel>