2010-04-23 7 views
2

WCF REST Contrib으로 .NET 3.5에서 REST 서비스를 설계하려고합니다. 내 서비스가 거의 정상적으로 작동하지만 기괴한 오류가 있습니다.UriTemplateTable 동사를 구분하지 않습니다.

[WebInvoke(UriTemplate = "/books?id={identity}", Method = "PUT")] 
public string InsertBook(string identity, Book book) 
{ 
// snipped 
} 

[WebInvoke(UriTemplate = "/books?id={identity}", Method = "GET")] 
public Books[] ListBooks(string identity) 
{ 
// snipped 
} 

그러나 내가 활성화시 오류 메시지가 점점 오전 :

System.InvalidOperationException 사용자 코드 메시지로 처리되지 않은했다

기본적으로, 나는 두 가지 방법이 = "UriTemplateTable은 템플리트와 동일한 경로를 갖는 다중 템플리트를 지원하지 않습니다. '/ books? id = {identity}'하지만 다른 쿼리 문자열을가집니다. trings은 모두 리터럴 값을 통해 명확하게 구분할 수 없습니다. 자세한 내용에 대한 UriTemplateTable 설명서를 참조하십시오. "출처 ="System.ServiceModel.Web "

/books2?identity 후 잘 작동 나는이 두 번째 방법을 이름을 변경합니다.

UriTemplateTable는 동사 구분되지 않는 이유 어떤 생각을 ?

답변

2

마지막으로 해결책을 발견.의 Web.config에서 바인딩이 (대신 기본 basicHttpBinding의) webHttpBinding로 지정해야합니다.

<system.serviceModel> 
    <services> 
    <service name="Foo.MyService"> 
     <endpoint address="" binding="webHttpBinding" contract="Foo.MyService" /> 
    </service> 
    </services> 
</system.serviceModel> 
관련 문제