2012-10-16 3 views
0

제가 만든 간단한 웹 서비스가 있습니다. Visual Studio 2012 .NET 4.5를 사용하고 있습니다.404 웹 서비스를 실행하려고 할 때 오류가 발생했습니다.

using System.Runtime.Serialization; 
using System.ServiceModel; 

namespace GEMS.Core.WCFService 
{ 
    [ServiceContract] 
    public interface IMenuService 
    { 
     [OperationContract] 
     void AddMenuItem(string menuId, string parentId, string title, string description, string url); 
     [OperationContract] 
     void UpdateMenuItem(string menuId, string parentId, string title, string description, string url); 
     [OperationContract] 
     void DeleteMenuItem(string menuId); 
     [OperationContract] 
     MenuEntry[] GetAllMenuItems(); 
    } 

    [DataContract] 
    public class MenuEntry 
    { 
     [DataMember] 
     public string MenuId { get; internal set; } 
     [DataMember] 
     public string ParentId { get; internal set; } 
     [DataMember] 
     public string Title { get; internal set; } 
     [DataMember] 
     public string Description { get; internal set; } 
     [DataMember] 
     public string Url { get; internal set; } 
    } 
} 

의 app.config의 관련 부분은 다음과 같습니다 : 여기

는 서비스 계약입니다

<system.serviceModel> 
    <services> 
    <service name="GEMS.Core.WCFService.MenuService"> 
     <host> 
     <baseAddresses> 
      <add baseAddress="http://localhost:8020/GEMS.Core.WCFService/MenuService/" /> 
     </baseAddresses> 
     </host> 
     <endpoint address="" binding="basicHttpBinding" contract="GEMS.Core.WCFService.IMenuService" > 
     <identity> 
      <dns value="localhost"/> 
     </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
    </services> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior> 
     <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> 
     <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

내 IIS 서버에 (내 상자 로컬)을 게시 할 수 있습니다.

클라이언트 응용 프로그램에서 서비스 참조를 만듭니다. 내가 발견을 클릭하면 찾습니다

There was no endpoint listening at: 
http://localhost:8020/GEMS.Core.WCFService/MenuService/ that could 
accept the message. This is often caused by an incorrect address or 
SOAP action. See InnerException, if present, for more details. 

내부 예외는 단지이 웹에서 404 오류를 가지고 있다고 말한다 :

http://localhost:8020/GEMS.Core.WCFService/MenuService/mex 

내 클라이언트를 실행하지만, 나는 다음과 같은 메시지가 뜹니다 섬기는 사람.

클라이언트의 .config 파일은 다음 자동 생성 된 XML이 있습니다

<system.serviceModel> 
    <bindings> 
    <basicHttpBinding> 
     <binding name="BasicHttpBinding_IMenuService" /> 
    </basicHttpBinding> 
    </bindings> 
    <client> 
    <endpoint address="http://localhost:8020/GEMS.Core.WCFService/MenuService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMenuService" 
     contract="WCF_MenuService.IMenuService" name="BasicHttpBinding_IMenuService" /> 
    </client> 
</system.serviceModel> 

나는 시간에서 빙빙 돌고있다 그리고 나는 최대 glitched 뭘 찾았는지 알아낼 수 없습니다, 그러나 확실하게 나는 틀린 일을했다.

중요한 것은 확실하지만 클라이언트는 ASP.NET MVC 앱입니다.

+4

클라이언트를 사용하지 않고 웹 브라우저에서 서비스 자체를 탐색 해 볼 수 있습니까? 일반적인 WCF 웹 페이지를 보지 못한다면 Windows 기능에서 WCF HTTP 활성화 (및 일부 다른 기능)를 켜야 할 가능성이 큽니다. –

+0

분명히 몇 가지 이상한 일들이 벌어지고 있습니다. 우선, 발견이 잘못된 URL을 얻고 있습니다. 실제 URL은 다음과 같습니다. localhost/GEMS.Core.WCFService.MenuService.svc 또한 서비스 참조를 생성 할 때 클래스를 생성하지 않습니다. 그러나 간단한 콘솔 앱을 만들고 서비스 참조를 만들면 위의 적절한 URL에서 제대로 작동합니다. 100 % 확신 할 수는 없지만 Newtonsoft.json이 생선을 일으킬 수있는 것처럼 보입니다. – Pete

+0

여전히 모든 것을 작동 시키려고하지만 첫 번째 단계는 다른 응용 프로그램에서 서비스 클라이언트를 만든 다음 실제 응용 프로그램으로 복사하고 네임 스페이스 참조를 변경하는 것입니다. VS.NET 문제 일 수 있습니다. – Pete

답변

1

Pete는 Newtonsoft.json.dll이 클라이언트가 서비스 코드를 생성하지 않도록 설명했습니다. dll을 삭제 한 다음 서비스 참조를 다시 추가 할 수 있습니다.

아니면 나를 위해 일한 해결책을 시도해 볼 수 있습니다. 창

  • 사용 안 함 '참조 된 어셈블리에서 재사용 유형'- 당신은 '서비스 참조 추가'에서 '고급 ...'버튼을 서비스 참조,

    1. 클릭을 추가 할 때.

    클래스가 생성되어야합니다.

  • 관련 문제