나는 게시 및 요청을 처리하는 방법을 보여주는 편안한 서비스의 골격 알고리즘을 만들고 있습니다. 내 예제에서 얻는 것은 잘 작동하지만 게시물은 그렇지 않습니다. 나는 내가 web.config에 물건을 추가해야한다고 생각하지만, 무엇과 왜 모르겠다. 미리 감사드립니다, 졸리.wcf 편안한 서비스 구성 오류
[ServiceContract]
public interface IRestfulService
{
[OperationContract]
[WebGet(UriTemplate = "/GetAStudent")]
Student GetExistingStudent();
[OperationContract]
[WebInvoke(UriTemplate = "/GetTheGivenStudent/{studentName}", Method = "POST")]
Student GetGivenStudent(string studentName);
}
public class RestfulService : IRestfulService
{
public Student GetExistingStudent()
{
Student stdObj = new Student
{
StudentName = "Foo",
Age = 29,
Mark = 95
};
return stdObj;
}
public Student GetGivenStudent(string studentName)
{
Student stdObj = new Student
{
StudentName = studentName,
Age = 29,
Mark = 95
};
return stdObj;
}
}
[DataContract]
public class Student
{
[DataMember]
public string StudentName { get; set; }
[DataMember]
public int Age { get; set; }
[DataMember]
public double Mark { get; set; }
}
의 Web.config : 당신은 REST 서비스에 대한 MEX 끝점을 노출 할 필요가 없습니다
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="webHttpBinding"/>
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior >
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
어느 것이 POST로 작동합니까? 첫 번째 메서드는 선언 된 메서드가 없으며 다른 메서드는 GET이됩니다. – Michel
예외는 무엇입니까? –
게시물을 수정했습니다. 지금 그것은 맞습니다, 나는 두 번째가 게시물로 작동 할 것으로 기대합니다. 내가 얻는 오류는 다음과 같습니다. 끝점을 찾지 못했습니다 –