내 서비스에서 얻으려고 시도 할 때 서비스 엔드 포인트로 실행되는 것으로 보이는 문제가 없습니다.서비스 끝 점이 없습니까?
시도하면 http://localhost:8000/hello/help 나는 <string>You entered help <string>
을 볼 것으로 예상되지만 대신에만 끝점을 얻지 못하나요? 나는 설정 파일에 전혀 영향을주지 않고 콘솔 앱에서만 호스팅하고 있습니다.
호스트 :
namespace Host
{
class Program
{
static void Main(string[] args)
{
WebHttpBinding binding = new WebHttpBinding();
WebServiceHost host =
new WebServiceHost(typeof(Service1));
host.AddServiceEndpoint(typeof(IService1),
binding,
"http://localhost:8000/hello");
host.Open();
Console.WriteLine("Hello world service");
Console.WriteLine("Press <RETURN> to end service");
Console.ReadLine();
}
}
}
서비스 1 :
namespace WcfServiceLibrary1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IService1
{
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
IService1 :
[ServiceContract]
public interface IService1
{
[WebGet(UriTemplate = "/{value}")]
string GetData(string value);
안녕하세요 저스틴 다시 내게있어/{value} 내 URL이 있기 때문에 : http : // localhost : 8000/안녕 끝내는 슬래시/나는 그것을 생각할 수도 있지만 상관 없어요. 문제. –
@Garrith 제 답변을 업데이트했으며 OperationContractAttribute도 누락되었습니다. –
LOL 운영 계약이 누락되었습니다! +1 –