【发布时间】:2011-08-08 17:34:07
【问题描述】:
我在项目中创建了 WCF 服务。现在使用 Jquery 我可以成功使用服务,但是当我尝试在 Windows 应用程序中添加服务作为 Web 引用时,我无法调用它。如果我创建简单的服务,我可以在 Windows 应用程序中成功调用,但是如果我更改为 jquery 调用服务,我通过谷歌搜索找到了。我不知道我错过了哪里。
下面是代码,我已经完成了。 这是 WCF 的接口。
[ServiceContract]
public interface ITestService
{
[OperationContract]
void DoWork();
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
string HelloWorld();
}
类调用接口
public class TestService : ITestService
{
public void DoWork()
{
}
public string HelloWorld()
{
return "Hello World";
}
}
}
这是应用程序的网络配置。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="TestWCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="TestWCFBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->
<services>
<service name="WebAppWithWCF.TestService" behaviorConfiguration="TestWCFBehavior">
<endpoint address="" binding="webHttpBinding" contract="WebAppWithWCF.ITestService" behaviorConfiguration="TestWCFBehavior"/>
</service>
</services>
</system.serviceModel>
我做了一些尝试和错误,但直到现在都找不到方法......
请帮助...如果我身边缺少任何信息,请告诉我。
【问题讨论】: