0
我是一位嘗試使用WCF的新手。我試圖使用Android訪問WCF,我遇到了麻煩,根據我的研究json需要訪問WCF,所以我試圖將其更改爲json。WCF中關於serviceHostingEnvironment的未處理錯誤
我改變了接口的對象類型,並開始具有低於
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>
我不知道爲什麼它不起作用。誰能幫幫我嗎?
GetUserId操作的參數類型是「Login」,但服務類型也是「Login」,它們是不同名稱空間中的兩種不同類型嗎?如果沒有,那可能是你的問題 - 服務名稱是服務的實現,在你的情況下,無論實現AddItemService.ILogin – kmp 2012-04-10 09:35:30