C# jquery和RESTful wcf服务
我在vs2012中使用了RESTful wcf服务。我可以通过网络浏览器访问此服务。我的接口文件是这样的:C# jquery和RESTful wcf服务,c#,jquery,wcf,C#,Jquery,Wcf,我在vs2012中使用了RESTful wcf服务。我可以通过网络浏览器访问此服务。我的接口文件是这样的: namespace RestService { [ServiceContract] public interface IRestServiceImpl { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageForm
namespace RestService
{
[ServiceContract]
public interface IRestServiceImpl
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle=WebMessageBodyStyle.Wrapped,
UriTemplate = "xml/{id}"
)]
string XMLData(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "json/{id}"
)]
string JSONData(string id);
}
}
我的配置文件是:
<system.serviceModel>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我必须做什么以及我必须写什么类型、url、数据、ContentType、datatype等。请帮助我工作了几天。从您的客户端调用它时,您会遇到什么错误 由于它是WCF,我想这是一个配置问题,请在您的.config文件中尝试
<standardEndpoint name="" helpEnabled="true"
automaticFormatSelectionEnabled="false"
defaultOutgoingResponseFormat ="Json" />
这里有一个很好的例子:我不确定,但你能试试这个吗:- 在ajax调用中,将url更改为
url:“localhost:50046/RestServiceImpl.svc/json/123”
任何人都可以帮助我捕获来自客户端的http流量,例如Fiddler,以及请求的外观。
<standardEndpoint name="" helpEnabled="true"
automaticFormatSelectionEnabled="false"
defaultOutgoingResponseFormat ="Json" />