매우 간단한 WCF 서비스를 HTTp Get과 함께 사용하려고 시도했지만 제대로 작동하지 않습니다. 우리는 그 "가이드"를 따라했지만 우리는 다음 URL에 우리의 서비스를 호출 할 때이HTTP와 함께 WCF 서비스를 사용하는 방법 (Visual studio 2010 내)
- http://msdn.microsoft.com/en-us/library/bb412178.aspx
- http://www.dotnetfunda.com/articles/article779-simple-5-steps-to-expose-wcf-services-using-rest-style-.aspx
작동하지 않습니다, 우리는 페이지를 찾을 수 없습니다 오류가 발생합니다 :
기본 URL (HTTP : // localhost를 : 9999/Service1.svc)이 잘 작동하고 올바르게 WCF 서비스 정보 페이지를 반환합니다.
이 코드는 예제를 재현하는 단계와 코드입니다.
- 비주얼 스튜디오 2010 년, 새로운 "WCF 서비스 응용 프로그램"프로젝트
이 코드
[ServiceContract()] public interface IService1 { [OperationContract()] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "GetData/{value}")] string GetData(string value); }
이 코드
으로 서비스 클래스를 교체 IService 인터페이스를 교체를 만들public class Service1 : IService1 { public string GetData(string value) { return string.Format("You entered: {0}", value); } }
web.config는 다음과 같습니다.
<system.web> <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="Service1"> <endpoint address="" binding="webHttpBinding" contract="IService1" behaviorConfiguration="WebBehavior1"> </endpoint> </service> </services> <behaviors> <endpointBehaviors> <behavior name="WebBehavior1"> <webHttp helpEnabled="True"/> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors>
- 을 눌러 실행과 사람이 나 뭔가 비슷한 작업을 진행하면 가져 오기 방법
에게 전화를 시도, 그것은 매우 종류의 수 있다면 것 작업 예제에 대한 회신 정보.
고맙습니다.
정말 옳습니다 ... 그것은 루트 네임 스페이스가 없기 때문입니다. 다른 바인딩에는 괜찮지 만 (루트 네임 스페이스없이) 작동하지만 webHttpBinding에서는 작동하지 않습니다. 고맙습니다. –