こんにちは私は既存のSOAPサービスにWebGetsとWebInvokesを追加しています。これは、GUID型変数をパラメーターとして受け取るメソッドです。WebGetは、そのuritemplateのパラメーターとして文字列以外のものを取得できないことを知っています。ただしhttp://baseaddress/Rest/GetInstitutionFromGuid?guid=106fbb94-34aa-403c-9400-f186e75e4793
、Advanced Rest Client chromeアドオンで""(106fbb94-34aa-403c-9400-f186e75e4793はサンプルGUID)のように実行すると、エラーは発生しませんが、nullが返されます。したがって、私の質問は、GUIDタイプのパラメータをWebGetのUriTemplateに渡すことができますか?GUIDから機関を取得するためにどのような種類のhttpリクエストを行う必要がありますか?
GetInstitutionFromGuidメソッドの操作コントラクトは次のとおりです。
[OperationContract]
[WebGet(UriTemplate = "Rest/GetInstitutionFromGuid&guid={guid}&format={format}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
[return: MessageParameter(Name = "Institution")]
Institution GetInstitutionFromGuid(Guid guid,String format);
その実装は次のとおりです。
public Institution GetInstitutionFromGuid(Guid guid,String format)
{
if (string.Equals("json", format, StringComparison.OrdinalIgnoreCase))
{
WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;
}
Institution inst = db.Institutions.Where(i => i.Guid == guid).FirstOrDefault();
return inst;
}