我在項目中創建了WCF服務。現在使用Jquery,我成功地能夠使用服務,但是當我嘗試在Windows應用程序中添加服務作爲Web引用時,我無法調用它。如果我創建簡單的服務,我可以在Windows應用程序中成功調用,但是如果我做了更改以調用jQuery的服務,那麼通過執行一些Google搜索就可以找到它。我不知道我在哪裏失蹤。在Windows應用程序中使用WCF服務?
下面是我所做的代碼。 這是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";
}
}
}
,這裏是應用程序的Web配置。
<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>
我已經做了一些嘗試和錯誤,但不能找到一種方法,到現在爲止...
請幫助...讓我知道,如果任何信息是從我的身邊缺少。
我們可以添加多個綁定,這是非常方便,當我們想暴露於多件事情。謝謝Max。 – kunjee
不客氣! – maxbeaudoin