2012-11-26 3 views
3

wcf 및 mtom을 사용하여 첨부 파일과 함께 이메일을 보낼 수있는 웹 서비스를 개발해야합니다. . 나는 내 일을 위해 다음 도구를 사용하여wcf webservice에서 mtom을 사용하여 바이너리 데이터를 스트리밍하는 중 오류가 발생 함 "HTTP 응답 *** 수신 중 오류가 발생했습니다"

윈도우 7 프로페셔널 64 마이크로 소프트 비주얼 스튜디오 2012 Microsoft 개발 서버/IIS 익스프레스 8.0 사용자 : 관리자

내가 내 클라이언트에서 웹 서비스를 사용하려고 할 때마다 메시지 계약의 자체 정의 된 클래스에 "HTTP 응답을받는 동안 오류가 발생했습니다 (http://localhost:2364/Service1.svc). 이는 HTTP 프로토콜을 사용하지 않는 서비스 끝점 바인딩 때문일 수 있습니다. 이는 HTTP 요청 컨텍스트 서버에 의해 중단되었습니다 (서비스가 종료되었을 가능성이 있습니다). 자세한 내용은 서버 로그를 참조하십시오.

이제 간단한 테스트 서비스와 간단한 테스트 클라이언트를 설정하려고합니다. 나는 다음과 같은 것들을 시도하고 항상 같은 오류를 얻는다. 요청과 응답에서 단순한 문자열을 사용하는 webservice의 메서드를 사용하는 것은 오류없이 아주 잘 작동한다. 클라이언트 및 서비스 구성은 BasicHttpBinding 나있는 wsHttpBinding을 사용하여 비주얼 스튜디오 2012 및 IIS 익스프레스 8.0

  • 같은 오류에서 통합 된 Microsoft 개발 서버에

    1. 같은 오류가

    2. 는 로그온 파일을 생성하는 시도 두 서버. IIS Express Server는 구성 파일 이외의 다른 폴더에 일부 로그를 생성하지만 구성 파일의 설정은 사용하지 않습니다. Microsoft Development Server는 아무 것도 생성하지 않습니다.

    3. 몇 가지 생성 된 로깅 파일을보기 위해 svctraceviewer.exe를 사용했으며 작업 코드 MODULE_SET_RESPONSE_ERROR_STATUS로 몇 가지 경고를 보았습니다. 나는이 정보를 이해할 수 없다.

    4. localService 및 networkService에 대한 읽기/쓰기 권한을 결과없이 지정된 폴더에 사용하려고했습니다.

    5. RawCap을 사용하여 로컬 호스트를 스니핑하고 wireshark로 결과를 보려고했지만 출력 파일에 0 바이트가 있습니다 (다른 문제 여야 함).

    추가 정보가 필요하면 알려주십시오.

    감사합니다.

    서비스 : 아래

    은 (단지 테스트 용) 서비스와 클라이언트에 대한 내 코드와 구성입니다 IService1.cs :

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Runtime.Serialization; 
    using System.ServiceModel; 
    using System.ServiceModel.Web; 
    using System.Text; 
    using System.IO; 
    
    namespace WcfTestService 
    { 
    
    [ServiceContract] 
    public interface IService1 
    { 
    
        [OperationContract] 
        string GetData(int value); 
    
        /* 
        [OperationContract] 
        CompositeType GetDataUsingDataContract(CompositeType composite);*/ 
    
        // TODO: Hier Dienstvorgänge hinzufügen 
    
        [OperationContract] 
        ServiceResponse TestCase(ServiceRequest testRequest); 
    } 
    
    /* 
    // Verwenden Sie einen Datenvertrag, wie im folgenden Beispiel dargestellt, um Dienstvorgängen zusammengesetzte Typen hinzuzufügen. 
    [DataContract] 
    public class CompositeType 
    { 
        bool boolValue = true; 
        string stringValue = "Hello "; 
    
        [DataMember] 
        public bool BoolValue 
        { 
         get { return boolValue; } 
         set { boolValue = value; } 
        } 
    
        [DataMember] 
        public string StringValue 
        { 
         get { return stringValue; } 
         set { stringValue = value; } 
        } 
    }*/ 
    
    [MessageContract] 
    public class ServiceRequest 
    { 
        [MessageHeader] 
        public String Type { get; set; } 
    
        [MessageBodyMember] 
        public Stream Contents { get; set; } 
    } 
    
    [MessageContract] 
    public class ServiceResponse 
    { 
        [MessageHeader] 
        public String Type { get; set; } 
    
        [MessageBodyMember] 
        public Stream Contents { get; set; } 
    } 
    } 
    

    서비스 : Web.config의 :

    <?xml version="1.0" encoding="utf-8"?> 
    <configuration> 
    
    <system.diagnostics> 
    <sources> 
        <source name="System.ServiceModel.MessageLogging" switchValue="Ausführlich,ActivityTracing"> 
        <listeners> 
         <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
         <filter type="" /> 
         </add> 
         <add name="ServiceModelMessageLoggingListener"> 
         <filter type="" /> 
         </add> 
        </listeners> 
        </source> 
        <source propagateActivity="true" name="System.ServiceModel" switchValue="Ausführlich,ActivityTracing"> 
        <listeners> 
         <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
         <filter type="" /> 
         </add> 
         <add name="ServiceModelTraceListener"> 
         <filter type="" /> 
         </add> 
        </listeners> 
        </source> 
    </sources> 
    <sharedListeners> 
        <add initializeData="d:\log\web_messages.svclog" 
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> 
        <filter type="" /> 
        </add> 
        <add initializeData="d:\log\web_tracelog.svclog" 
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> 
        <filter type="" /> 
        </add> 
    </sharedListeners> 
    <trace autoflush="true" /> 
    </system.diagnostics> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <!--httpRuntime targetFramework="4.5"/>--> 
    <httpRuntime targetFramework="4.5" maxRequestLength="102400" executionTimeout="7200"/> 
    </system.web> 
    <system.serviceModel> 
    <diagnostics> 
        <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true" 
        logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> 
        <endToEndTracing propagateActivity="true" activityTracing="true" 
        messageFlowTracing="true" /> 
    </diagnostics> 
    <bindings> 
        <basicHttpBinding> 
        <binding name="basicHttpMtomBinding" closeTimeout="10:01:00" 
         openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" 
         transferMode="Streamed" messageEncoding="Mtom"> 
         <readerQuotas maxDepth="1000" maxStringContentLength="1000" maxArrayLength="1000" 
         maxBytesPerRead="1000" maxNameTableCharCount="1000" /> 
        </binding> 
        </basicHttpBinding> 
        <wsHttpBinding> 
        <binding name="wsHttpMtomBinding" closeTimeout="10:01:00" openTimeout="10:01:00" 
         receiveTimeout="10:10:00" sendTimeout="10:01:00" maxBufferPoolSize="999999999" 
         maxReceivedMessageSize="1048576" messageEncoding="Mtom" 
    useDefaultWebProxy="true"> 
         <readerQuotas maxDepth="100" maxStringContentLength="1000" maxArrayLength="1000" 
         maxBytesPerRead="100000" maxNameTableCharCount="1000" /> 
         <reliableSession inactivityTimeout="10:10:00" /> 
         <security mode="None" /> 
        </binding> 
        </wsHttpBinding> 
    </bindings> 
    <behaviors> 
        <serviceBehaviors> 
        <behavior> 
         <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
         <serviceDebug includeExceptionDetailInFaults="true"/> 
        </behavior> 
        </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
        <remove scheme="http" /> 
        <add scheme="http" binding="wsHttpBinding" bindingConfiguration="wsHttpMtomBinding" /> 
        <add scheme="https" binding="basicHttpsBinding" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
    multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
        Um das Stammverzeichnis der Webanwendung beim Debuggen auszuwählen, legen Sie den Wert unten auf "true" fest. 
        Legen Sie ihn vor der Bereitstellung auf "false" fest, um die Veröffentlichung von Informationen über den Webanwendungsordner zu vermeiden. 
        --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 
    
    </configuration> 
    

    클라이언트 : app.설정 :

    <?xml version="1.0" encoding="utf-8" ?> 
    <configuration> 
    <system.serviceModel> 
        <bindings> 
         <wsHttpBinding> 
          <binding name="WSHttpBinding_IService1" messageEncoding="Mtom"> 
           <security mode="None" /> 
          </binding> 
         </wsHttpBinding> 
        </bindings> 
        <client> 
         <endpoint address="http://localhost:2364/Service1.svc" binding="wsHttpBinding" 
          bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1" 
          name="WSHttpBinding_IService1"> 
          <identity> 
           <userPrincipalName value="Ares\Admin" /> 
          </identity> 
         </endpoint> 
        </client> 
    </system.serviceModel> 
    </configuration> 
    

    클라이언트 : Form1.cs를 내가 Web.config의에서 모든 서비스 구성 데이터를 볼 수 없습니다

     ... 
    
         private void button1_Click(object sender, EventArgs e) 
        { 
    
         ServiceReference1.IService1 testService = new ServiceReference1.Service1Client(); 
         ServiceReference1.ServiceRequest testInput = new ServiceReference1.ServiceRequest(); 
         ServiceReference1.ServiceResponse testOutput = new ServiceReference1.ServiceResponse(); 
    
         BinaryFormatter formatter = new BinaryFormatter(); 
         MemoryStream inoutStream = new MemoryStream(); 
    
         testInput.Type = "TestType"; 
         String test = "TestContent"; 
         testInput.Contents = new MemoryStream(); 
         formatter.Serialize(testInput.Contents, test); 
         //testInput.Contents.Position = 0; 
    
         testService.TestCase(testInput); 
    
    
         MessageBox.Show("Done!"); 
    
        } 
    
        ... 
    
  • 답변

    0

    (엔드 포인트 등)

    <services> 
         <service behaviorConfiguration="..." name="[Namespace].Service1"> 
         <endpoint address="" binding="basicHttpBinding" bindingNamespace="..." bindingConfiguration="..." contract="[Namespace].IService1"> 
          <identity> 
          <dns value="localhost" /> 
          </identity> 
         </endpoint> 
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
         <host> 
          <baseAddresses> 
          <add baseAddress="http://localhost:5000/Service1"/> 
    ... 
    

    당신에게 (기본적으로 자체 호스팅 서비스에서) 엔드 포인트를 구성 할 수 있지만 간단한 시나리오와 IIS 인프라에서는 ...?

    http://msdn.microsoft.com/en-us/library/ee354381.aspx