收到错误消息“远程服务器返回错误:(404)未找到。”在客户端应用程序中使用WCF服务时

时间:2018-07-10 12:07:15

标签: asp.net wcf asp.net-web-api

我已经将WCF托管在本地主机上。这是我的配置文件,服务和客户端。我是WCF的新手。 为什么不起作用? 我正在访问方法的json o / p绑定客户端应用程序中的gridview。 但是它给出了404错误。请调查我的问题。

服务配置:

<system.servicemodel>
<services>
<service name="AdvaitWCF2.CustodianService" behaviorConfiguration="serviceBehavior">
<endpoint address="http://localhost:46292/CustodianService.svc" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="RestBinding" contract="AdvaitWCF2.ICustodianService">
<identity>
<dns value="localhost" />   

<endpoint contract="IMetadataExchange" binding="mexHttpBinding"
address="mex" />
<host>
<baseaddresses>
<add baseAddress="http://localhost:46292/CustodianService.svc"/>

<bindings>

<webhttpbinding>
<binding name="RestBinding">
<readerQuotas maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" />
<security mode="None">

<behaviors>
<endpointbehaviors>
<behavior name="webBehavior">
<webHttp helpEnabled="true"/>
<servicebehaviors>
<behavior name="serviceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />

<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />

<protocolmapping>
<add binding="basicHttpsBinding" scheme="https"/>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />

客户端配置:

<system.servicemodel>

<bindings>

<webhttpbinding>

<binding name="BasicHttpBinding_ICustodianService" >

<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />

<client>
<endpoint 
name="ServiceReference1.CustodianService"
address="http://localhost:46292/CustodianService.svc" 
binding="webHttpBinding" 
contract="ServiceReference1.ICustodianService" 
behaviorConfiguration="webEndpoint" 
bindingConfiguration="BasicHttpBinding_ICustodianService"
/>

<behaviors>
<endpointbehaviors>
<behavior name="webEndpoint">
<webHttp defaultBodyStyle="Wrapped" 
defaultOutgoingResponseFormat="Json" 
helpEnabled="true"/>

0 个答案:

没有答案