[英]I am getting error in consuming WCF service
我在stackoverflow中看到了很多答案,但它们并没有帮助我。 我有一个wcf服务,当我运行它时,它会在浏览器上显示有效的输出。当我在jquery客户端中使用它时,它没有给出任何输出。我想使用该wcf服务来绘制图形,以下是我的配置文件
<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="web">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
</system.serviceModel>
以下是我的cs代码
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method="GET",ResponseFormat=WebMessageFormat.Json,BodyStyle=WebMessageBodyStyle.Wrapped,UriTemplate="empdetials")]
List<employee> empdetials();
}
以下是我的客户端代码
$(document).ready(function () {
var sourcee = {};
$.ajax({
cache: false,
async: true,
type: "GET",
url: "http://localhost:1331/Service1.svc/empdetials",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert(data.d);
sourcee = $.parseJSON(data.d);
alert(sourcee);
},
error: fnerrorcallback
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.