2014-03-31 5 views
2

wcf 서비스를 만들었지 만 실행하면 다음과 같은 오류가 표시됩니다.내 wcf 서비스를 실행할 수 없습니다.

enter image description here 이름 바꾸기 도구를 사용하여 이름 클래스와 인터페이스 이름을 변경했습니다.

[ServiceContract] 
public interface MyServices 
{ 

    [OperationContract] 
    string MyTask1(string myValue); 
    [OperationContract] 
    string MyTask2(DataContract1 dcValue); 

} 

// Use a data contract as illustrated in the sample below to add composite types to service operations. 
[DataContract] 
public class DataContract1 
{ 
    string firstName; 
    string lastName; 
    [DataMember] 
    public string fname 
    { 
     get { return firstName; } 
     set { firstName = value; } 
    } 
    public string lname 
    { 
     get { return lastName; } 
     set { lastName = value; } 
    } 
} 

내 web.config 파일을 편집하고, (나는 검은 색으로 읽을이 라인을 추가했습니다 : 여기 는

여기
public class MyTest : MyServices 
{ 
    public string MyTask1(string a) 
    { 
     return "Hello " + a; 
    } 
    public string MyTask2(DataContract1 dc) 
    { 
     return "Hello " + dc.fname; 
    } 
} 

내 인터페이스에 대한 코드입니다 service.cs 클래스에 대한 코드 책) 여기

<service name="Service" behaviorConfiguration="ServiceBehavior"> 
     <!--Service EndPoints--> 
     <endpoint address="" binding="wsHttpBinding" contract="MyServices"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadatExchange"/> 
     </service> 

내는 system.serviceModel 코드

<system.serviceModel> 
    <services> 
     <!-- My Custimization --> 
     <service name="Service" behaviorConfiguration="ServiceBehavior"> 
     <!--Service EndPoints--> 
     <endpoint address="" binding="wsHttpBinding" contract="MyServices"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadatExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https"/> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
+0

나는이 라인을 이해하지 못한다. 어떤 목적으로 쓰여졌는지

+1

메타 데이터 또는 서비스 설명을 얻기위한 바인딩이다. . 비활성화 된 경우 wsdl을 가져올 수 없습니다. –

+0

'ServiceBehavior' 설정을 보여줄 수 있습니까? 아니면' 섹션 전체를 최상으로 만들 것인가? – Szymon

답변

0

맞춤법 실수는 내가 ...

IMetadatExchange -- > IMetadataExchange 

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadatExchange"/> 

이 시도 .. 추측 기존의 웹 서비스에

<system.serviceModel> 
    <services> 
     <!-- My Custimization --> 
     <service name="Service" behaviorConfiguration="ServiceBehavior"> 
     <!--Service EndPoints--> 
     <endpoint address="" binding="wsHttpBinding" contract="MyServices"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
      <endpoint address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https"/> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
+0

괜찮습니다. 하지만 어떤 목적으로 코드 라인을 작성했는지 알려주시겠습니까? (나는 mex를 의미합니다)

1

1) 우리는 WSDL을 사용하여 프록시를 만들 수 있습니다. WSDL은 웹 서비스 메타 데이터를 노출합니다. wcf에서 또 다른 용어는 메타 데이터를 노출하는 mex 끝 점이되지만 wsdl은 wcf.i에 아직 살고 있습니다. 따라서 wcf에서 새로운 것입니다. 따라서 wsdl & mex 끝점의 차이점은 무엇입니까?

mex는 비 HTTP 프로토콜을 지원하고 고급 구성/보안 시나리오를 지원하도록 설계되었습니다. WSDL은 레거시 방식이며 MEX는 WCF의 새로운 향상된 버전입니다. 의 의미가 무엇인지

2) httpGetEnabled = "거짓"또는 httpGetEnabled = "true"를

당신이 MEX 끝점을 정의하지 않는 경우에도 그것은의 defautl의 URL을 통해 WSDL을 통해 메타 데이터를 노출합니다

당신의 서비스.

3) httpGetEnabled = "false"로 설정하면 어떻게됩니까? 클라이언트가 IDE에서 서비스 참조를 추가 할 수 없다는 뜻입니까? 하지만 httpGetEnabled = "false"로 설정하고 클라이언트가 서비스 참조를 추가 할 수 있음을 확인했습니다. 그래서 httpGetEnabled가 거짓인지 true인지는 매우 혼란 스럽습니다.

클라이언트는 httpGetEnabled/httpsGetEnabled가 활성화되어 있거나 서비스 구성에서 mex 끝점을 정의한 경우에만 VS에 참조를 추가 할 수 있습니다. 가장 좋은 방법은 제작 환경이 아닌 개발 환경에 메타 데이터를 노출하는 것입니다. 별도의 어셈블리를 통해 서비스 계약을 배포하고 ChannelFactory를 사용할 수도 있습니다.

4) 한 사람은 다음과 같이 말했습니다. - MEX와 WSDL은 잠재 고객에게 서비스 구조에 대해 알리는 두 가지 방법입니다. 따라서 서비스 계약을 (MEX) 또는 WSDL로 공개하도록 선택할 수 있습니다. 위의 문장이 사실이라면 MEX & 언제 WSDL을 사용해야할까요?

WSDL은 일반적으로 구성 할 수없는 http 또는 https get URL을 통해 노출됩니다 (보안 제한이나 이전 버전과의 호환성을 위해). MEX 엔드 포인트는 구성 가능한 엔드 포인트를 통해 메타 데이터를 노출하며 TCP 또는 HTTP와 같은 다양한 유형의 전송 및 다양한 유형의 보안 메커니즘을 사용할 수 있습니다.

따라서 MEX는 더 구성 가능하며 WSDL은 이전 버전의 WSDL로 작업하는 클라이언트와 비표준 클라이언트와 상호 운용이 가능합니다. 내가 MEX 해제하고

이 설정에 MEX 끝점을에서 지정할과 httpGetEnabled을 사용하지 마십시오 단지 WSDL을 통해 내 서비스에 노출 될 수 방법

5)

6) WSDL 지원 wshttp, wsdualhttp 또는 TCP 같은 모든 bidning ...

노출 메타 데이터는 서비스를 호출하는 것과 완전히 다릅니다.

UPDATE 당신이 설정에서 어떤 MEX 엔드 포인트 관련 항목이어야하며 httpgetenable

예처럼 보일 것이라는 점을 의미하려고 다시, 당신은 MEX 엔드 포인트 및 httpGetEnabled을 지정할 필요가 없습니다. 하나만 메타 데이터를 노출해야합니다. httpGetUrl은 호스팅 환경에 따라 다르므로 지정하지 마십시오.

mex는 설정 가능하지만 wsdl은 그렇지 않습니다. 어떤 메신저가 mex를 구성하려고하는지 알기 위해 ... 어떤 구성의 mex 지원을 & 구성하는 방법을 토론하십시오.

MEX 끝점은 클라이언트가 http get 요청 대신 SOAP 메시지를 사용하여 서비스의 메타 데이터를 수신 할 수있게 해주는 특수 끝점입니다. http, https, tcp 및 심지어 명명 된 파이프를 통해 액세스 할 수있는 MEX 끝점을 만들 수 있습니다. HttpGetEnable을 사용하면 HTTP GET 메서드를 통해 메타 데이터를 노출 할 수 있습니다. 대개 '? wsdl'접미사가 붙은 서비스의 주소

MEX 및 WSDL은 거의 동일한 내용을 출력합니다.

대부분의 경우 MEX 엔드 포인트가 필요하지 않습니다. 일반적으로 http get과 함께 WSDL을 사용하면 충분합니다.

본인은이 부분을 이해하려는 의도를 이해하지만이 부분에 대해 많은 시간을 할애하지 않습니다. 다른 많은 복잡한 기능이 있습니다!

+0

http://stackoverflow.com/a/21522849/391994 – foldinglettuce

관련 문제