WCF 服务 - 无法调用服务 - JSON
WCF Service - Failed to Invoke service - JSON
Failed to invoke the service. Possible causes: The service is offline
or inaccessible; the client-side configuration does not match the
proxy; the existing proxy is invalid. Refer to the stack trace for
more detail. You can try to recover by starting a new proxy, restoring
to default configuration, or refreshing the service.
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);
所以我认为我收到此错误是因为使用了 WCF 客户端工具,该工具目前不适用于使用 json 的 wcf。我尝试使用 fiddle 并得到一些不同的东西 HTTP/1.1 400 Bad Request.
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.
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);
所以我认为我收到此错误是因为使用了 WCF 客户端工具,该工具目前不适用于使用 json 的 wcf。我尝试使用 fiddle 并得到一些不同的东西 HTTP/1.1 400 Bad Request.