使用GUID + Windows 8进行身份验证

时间:2012-09-25 14:34:22

标签: c# wcf microsoft-metro

当我向MVC3应用程序添加服务引用时:我获取了在参数中使用guid的方法:

void getcities( string token);
void getCountry( string token);

但是当我向Windows 8应用程序添加服务引用时,生成的代理不包含令牌:

public System.Threading.Tasks.Task<Maquette_MyAirport_Win8.ServiceFlightInfo.CitiesResponse> GetAllCitiesAsync() 
{
  Maquette_MyAirport_Win8.ServiceFlightInfo.BaseRequest inValue = new Maquette_MyAirport_Win8.ServiceFlightInfo.BaseRequest();

  return ((Maquette_MyAirport_Win8.ServiceFlightInfo.FlightInfoService)(this)).GetAllCitiesAsync(inValue);
}

因此,当我在没有guid的情况下调用此方法时,会抛出错误:您无权访问此服务。

你有什么解决方案吗?

1 个答案:

答案 0 :(得分:0)

响应是Windows 8中不支持[System.ServiceModel.MessageHeaderAttribute]。

所以我添加这样的自定义行为来注入headermessage: How to add a custom HTTP header to every WCF call?

相关问题