WCF服务 - 无法调用服务 - JSON

时间:2015-06-12 20:15:09

标签: c# json wcf

  

无法调用该服务。可能的原因:服务处于脱机状态   或无法进入;客户端配置与   代理;现有代理无效。请参阅堆栈跟踪   更多详情。您可以尝试通过启动新代理进行恢复,然后进行恢复   默认配置或刷新服务。

The Address property on ChannelFactory.Endpoint was null.  The ChannelFactory's Endpoint must have a valid Address specified.
   at System.ServiceModel.ChannelFactory.CreateEndpointAddress(ServiceEndpoint endpoint)
   at System.ServiceModel.ChannelFactory`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at InstantBankVerificationPostBackClient.PostBack(String data)

Web.Config中:

<services>
    <service behaviorConfiguration="DebugJSonBehavior" name="IBVWebService.InstantBankVerificationPostBack">
        <endpoint address="http://localhost:64337/InstantBankVerificationPostBack.svc" 
            binding="webHttpBinding"
            contract="IBVWebService.IInstantBankVerificationPostBack"
            behaviorConfiguration="webBehavior">
            <identity>
              <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
</services>

<behaviors>
    <endpointBehaviors>
        <behavior name="webBehavior">
            <webHttp/>
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="DebugJSonBehavior">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
        </behavior>
    </serviceBehaviors>
</behaviors>

接口

[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json)]
void PostBack(string data);

1 个答案:

答案 0 :(得分:0)

所以我相信我收到此错误是因为使用了WCF客户端工具,该工具目前无法使用json使用wcf。我尝试了小提琴,我得到了一些不同的HTTP / 1.1 400 Bad Request。