2011-10-03 8 views
0

안녕하세요. 안녕하세요. 안녕하세요. 저는 안녕하세요. 안녕하세요.WCF 용 서비스 모델 구성

은 IIS 7에서 배포하고 괜찮습니다,하지만 난 웹 서비스를 테스트하기 위해 CMD를 통해 svcutil.exe http://localhost:4569/Service.svc?wsdl을 할 때 얻을 실행 :

the remote server returned an error: 415 cannot proccess the message because the content type 'aplication/soap+xml charset=utf8' was not the expected type 'text/xml charset=utf8'

(클라이언트를 만드는) 서비스 참조를 추가하려고

<configuration> 
     <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
     </system.web> 
     <system.serviceModel> 
<services> 
     <service name="Service"> 
      <endpoint name="soap" 
       address="http://localhost:4569/Service.svc" 
       binding="basicHttpBinding" 
       contract="IService" /> 
      <endpoint name="mex" address="mex" binding="mexHttpBinding" 
         contract="IMetadataExchange" /> 
     </service> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior> 
        <serviceMetadata httpGetEnabled="true"/> 
        <serviceDebug includeExceptionDetailInFaults="false"/> 
       </behavior> 
      </serviceBehaviors> 
</services> 
     </behaviors> 
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
     </system.serviceModel> 
     <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"/> 
     </system.webServer> 
    </configuration> 
: 난 내 Web.config 파일에서 문제가 있음을 확신

An existing connection was forcibly closed by the remote host Metadata contains a reference that cannot be resolved: 'http://localhost:4569/Service.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4569/Service.svc . The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..

IService.cs :

어쨌든, 여기 내 코드의

내 service.cs

[ServiceContract] 
public interface IService 
{ 
    [OperationContract] 
    string getMessage(); 
} 

public class Service : IService 
{ 
    public string getMessage() 
    { 
     return "Ola servico"; 
    } 
} 

난 정말 무슨 일이 일어나고 있는지 모르는했던 방법이있다 약간의 연구 후 일부 테스트지만 성공하지 못합니다.

Service.svc

<%@ ServiceHost Language="C#" Debug="true" Service="Service" CodeBehind="~/App_Code/Service.cs" %>   
+2

설정의 ** 재미있는 ** (** 중요 **) 부분을 표시하지 않습니다! 서버 측의''에있는''섹션과 * .svc 파일의 내용! 그것들을 추가하십시오 - 그렇지 않으면 우리는 최고로 추측을 남겼습니다 ... –

+1

은 전체 설정 파일입니까? 코드에 정의 된 서비스, 바인딩 및 끝점입니까? – MLT

+0

오류 메시지는 SOAP 및 REST가 혼합되어 있음을 나타냅니다. WSDL을 가져오고 싶지만 REST 바인딩 ('webHttpBinding')을 사용하는 것처럼 보입니다. –

답변

1

당신은 당신의 설정에 정의 된 서비스 및 엔드 포인트가 없습니다. 추가해보기

<services> 
    <service name="Service"> <!-- name should match the name in your .svc file (if you open it with a text editor) --> 
    <endpoint name="soap" address="" binding="basicHttpBinding" contract="IService" /> 
    <endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 
+0

DonAndre를 시도했지만 작동하지 않습니다. 어쨌든 서비스 섹션으로 내 질문을 편집했습니다. – Tiago

+0

구성이 게시 한 방식대로 작동하지 않습니다. 행동을 취하기 전에 서비스를 종료해야합니다. 비누 끝 점의 주소는 빈 문자열이어야합니다. 이는 URL의 .svc 다음에 나오는 내용을 참조하기 때문입니다. – Andreas

+0

@ 알고 있듯이, 코드는 그런 식으로 컴파일되지 않습니다. 실수를 저기에 넣었지만 코드에 맞습니다. – Tiago