我有一个问题,让jQuery从WCF服务检索结果。我在IIS中托管WCF服务,当我将调试器附加到此过程中时,我可以看到代码已成功处理。但是,当它在jQuery中触发回调没有数据?WCF服务没有返回值到jQuery
我已经在wcf服务上设置了跟踪并且没有错误。它看起来好像在wcf服务方法完成后数据丢失了。
这里是调用服务的jQuery代码:
$.get("http://ecopssvc:6970/ecopsService.svc/Echo", {echoThis: "please work"}, function(data) {
alert("Data Loaded: " + data);
});
这里是WCF配置:
<system.serviceModel>
<services>
<service name="EcopsWebServices.EcopsService" behaviorConfiguration="EcopsServiceBehaviours">
<endpoint address="" behaviorConfiguration="WebBehaviour"
binding="webHttpBinding" bindingConfiguration="" contract="EcopsWebServices.IEcopsServiceContract" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehaviour">
<webHttp />
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="EcopsServiceBehaviours">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
这里是服务合同:
[ServiceContract]
public interface IEcopsServiceContract
{
[WebGet]
[OperationContract]
string Echo(string echoThis);
}
这里是服务实施:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class EcopsService : IEcopsServiceContract
{
#region IEcopsServiceContract Members
public string Echo(string echoThis)
{
return string.Format("You sent this '{0}'.", echoThis);
}
#endregion
}
请帮助别人!!!
您是否在页面上使用ASP.Net并通过''元素引用服务? –
2010-03-10 12:27:28
您是否监控网络流量? (也许使用Fiddler或FireBug)..只需要找出失败点。 – Noel 2010-03-10 12:29:51
感谢您的回应家伙。我没有使用元素。我不相信这是必要的。我发现这个网页http://dotnetdiscoveries.blogspot.com/2008/05/using-jquery-with-json-enabled-wcf。在我搜索谷歌期间,他已经实施它和我一样,除了他的版本的作品?! 诺埃尔,我用Firebug和我收到一个空回应...... –
smithy
2010-03-10 12:50:34