我是一个尝试 WCF 的新手。我正在尝试使用 android 访问 WCF,我遇到了麻烦,根据我的研究,访问 WCF 需要 json,所以我尝试将其更改为 json。
我将接口更改为对象类型并开始出现如下所示的错误
The exception message is: The type 'AddItemService.Login', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
我的接口方法:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "Login", BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
[Description("Returns the Login User ID")]
int GetUserId(Login login);
我的 web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="AddItemService.Login"
behaviorConfiguration="RESTBehavior">
<endpoint address=""
binding="webHttpBinding"
contract="AddItemService.ILogin"
behaviorConfiguration="MyEndpointBehavior"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MyEndpointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
我不知道为什么它不起作用。谁能帮帮我吗?