2011-12-13 3 views
2

첫 번째 WCF 서비스를 만들려고합니다. 문제가 있습니다. 구조체, 클래스 및 몇 가지 메소드를 작성했습니다. 내 서비스 계약은 다음과 같습니다wcf 서비스가 작동하지 않습니다. 서비스를 추가하지 못했습니다.

는 서비스를 추가하지 못했습니다 : 나는 Visual Studio에서 테스트 클라이언트를 사용하여 실행하면

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.Text; 

namespace WebshopReports 
{ 
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IReports" in both code and config file together. 
    [ServiceContract] 
    public interface IReports 
    { 
     [OperationContract] 
     List<Category> getReportCategories(string dir); 

     [OperationContract] 
     List<CReport> getReportList(Category category); 

    } 
} 

, 나는 다음과 같은 얻을. 서비스 메타 데이터에 액세스 할 수 없습니다. 서비스가 실행 중이고 메타 데이터가 노출되어 있는지 확인하십시오.

나는 web.config 파일과 관련이 있다고 확신한다. 그것은 아래에 있습니다. 내가 Web.config를 구성하는 방법을 잘 모르는 나처럼 누군가가 나를 도와 주시겠습니까 : 내가 구조체에 클래스에서 C 보고서를 변경하는 경우

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <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> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

이상한 일입니다, 그것은 작동합니다.

답변

0

CReport이 serializable인지 확인해야합니다. 그렇지 않으면 WCF가 메타 데이터를 작성하여 (귀하의 경우에는 WSDL을 통해) 서비스를 교환 할 수 없습니다. 속성을 CReport 클래스에 추가하는 방법에 대해 읽어보십시오. 서버 측에서

1) 직렬화 :

우리의 경험에서
+0

아마도 내 솔루션을 잘못보고 있습니다. 매개 변수를 받아들이고 크리스탈 보고서를 실행하고 데이터를 반환하는 서비스를 만들고 싶습니다. 이 문제를 해결하는 가장 좋은 방법은 WSDL 서비스입니까? – Lock

+0

여러 가지 방법이있을 수 있습니다. 웹 서비스가 올바른 솔루션인지 판단하기 위해 제약 조건을 평가해야합니다. 확실한 답을주기위한 요구 사항에 대해 충분히 알지 못합니다. 이는 원래 질문의 범위를 벗어납니다. –

1

, 이러한 유형의 실패의 두 가지 주요 원인이있다. 이것은, 직렬화 가능하지 않은 클래스 또는 KnownType 속성을 사용하지 않고 추상 클래스를 직렬화하려고했기 때문일 수 있습니다.

2) 동일한 일반 서명이있는 여러 Collection 또는 Dictionary 유형 클래스 간의 WCF 혼란으로 인해 클라이언트 측에서 직렬화됩니다.

설명에 따르면 항목 1이 문제라는 것 같습니다.

이 당신의 web.config 파일의 구성 섹션에 다음 블록을 추가하는 것입니다 같은 WCF 문제를 해결하는 가장 좋은 방법 :

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" 
       switchValue="Information, ActivityTracing" 
       propagateActivity="true"> 
     <listeners> 
      <add name="traceListener" 
       type="System.Diagnostics.XmlWriterTraceListener" 
       initializeData="c:\log\WebTrace.svclog" /> 
     </listeners> 
     </source> 
    </sources> 
    </system.diagnostics> 

당신이 인터페이스를 사용하려고하면 그것은 실패, 두 번 svclog 파일을 클릭하면 WCF의 로그 뷰어 도구가 열립니다. 발생하는 모든 예외는 빨간색으로 강조 표시되고 해당 예외를 드릴 다운하여 WCF 서비스가 중단되는 특정 문제를 볼 수 있습니다.

0

CReport를 Serializable으로 표시했는지 다시 한 번 확인하십시오. 그러면 WCF 직렬화 기에서 클래스 정의를 WCF 메타 데이터에 표시 할 수 있습니다.

0

내가 잘못하지 않은 경우. 구성에서 모든 서비스 노드를 찾을 수 없습니다. 당신이 당신의 구성 파일에

<configuration> 
     <System.ServiceModel> 
     <Services> 
     <Service name="YourService.Somthing"> 
     <EndPoint name="default" address="" binding="basicHttpBinding" bindingConfiguration="" contract="YourContrat.Something"></Endpoint> 
     <endpoint kind="mexEndpoint" address="/mex" /> 
     </Service> 
     </Services> 
<System.ServiceModel> 
</configuration> 

희망 같은 것을 inlude해야이 도움이됩니다.

감사합니다.

1

내 웹보세요.구성, 나는 당신의 설정 파일이 잘못되었다고 생각합니다 :

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="NoneSecurity" 
      maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false"> 
      <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/> 
      <security mode="None"/> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="Elong.GlobalHotel.Host.IHotelAPIBehavior" 
     name="Elong.GlobalHotel.Host.IHotelAPI"> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Elong.GlobalHotel.Host.IIHotelAPI"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="Elong.GlobalHotel.Host.IHotelAPIBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
관련 문제