2010-07-09 2 views
0

WP7 용으로 개발중인 프로그램에 매우 특이한 문제가 있습니다. 먼저 배경, HttpWebRequest/Response를 비동기 적으로 사용하는 스트리밍 견적 응용 프로그램을 개발 중입니다. 나는 또한 모든 것이 올바른지 확인하기 위해 피들러의 모든 것을 모니터링하고 있습니다.WP7 (Windows Phone 7) 및 Fiddler의 HTTP 스트리밍 문제

따옴표는 항상 열려있는 HTTP 연결을 통해 서버로 들어옵니다. 로깅은 잘 작동하고 견적 신청서를 제출해야합니다. 문제는 (이 EndGetResponse을 얻을 수 없다) 내가하지 않으면 난 다시 응답을받지 않을 것입니다 두 가지 중 하나를

1 재발급 2는 피들러의 RequestBuilder

을 통해 동일한 요청을 제출 피들러 을 통해 오픈 가입 요청

내 노트북의 시뮬레이터에서이 응용 프로그램을 실행하려고했지만 응용 프로그램이 작동하지 않아 프로토콜 예외가 있지만 다른 스레드에 대한 질문입니다.

아이디어가 있으십니까? Fiddler를 통해 스트리밍 데이터와 관련이 있다고 생각합니다. 피들러 제거, 캡쳐 해제, WinInet에서 프록시 설정 실행 취소 시도했지만 아무것도 작동하지 않았습니다. 이것은 나를 미치게하고, 그래서 당신의 도움은 크게 감사하게 될 것입니다.

업데이트 : 트위터의 스트리밍 API로이 작업을 재현 할 수있었습니다. 아래는 새로운 코드입니다.

에서 MainPage.xaml :

<phoneNavigation:PhoneApplicationPage 
    x:Class="TestHttpStreaming.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}"> 

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <!--TitleGrid is the name of the application and page title--> 
     <Grid x:Name="TitleGrid" Grid.Row="0"> 
      <TextBlock Text="MY APPLICATION" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}"/> 
      <TextBlock Text="page title" x:Name="textBlockListTitle" Style="{StaticResource PhoneTextPageTitle2Style}"/> 
     </Grid> 

     <!--ContentGrid is empty. Place new content here--> 
     <Grid x:Name="ContentGrid" Grid.Row="1"> 
      <Button Content="Test" Height="70" HorizontalAlignment="Left" Margin="163,149,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" /> 
     </Grid> 
    </Grid> 

</phoneNavigation:PhoneApplicationPage> 

MainPage.xaml.cs를 :

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using Microsoft.Phone.Controls; 
using System.IO; 

namespace TestHttpStreaming 
{ 
    public partial class MainPage : PhoneApplicationPage 
    { 
     public MainPage() 
     { 
      InitializeComponent(); 

      SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape; 
     } 

     Uri uri = null; 
     HttpWebRequest request = null; 
     byte[] buffer = new byte[1024]; 
     Stream stream = null; 
     private void button1_Click(object sender, RoutedEventArgs e) 
     { 
      uri = new Uri("http://stream.twitter.com/1/statuses/sample.json?delimited=length", UriKind.Absolute); 
      request = (HttpWebRequest)WebRequest.Create(uri); 
      request.Method = "GET"; 
      request.Credentials = new NetworkCredential("[username]", "[password]"); 
      request.BeginGetResponse(new AsyncCallback(this.EndGetResponseStream), null); 
     } 
     void EndGetResponseStream(IAsyncResult result) 
     { 
      try 
      { 
       HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); 
       stream = response.GetResponseStream(); 
       IAsyncResult iarRead = stream.BeginRead(buffer, 0, 1024, new AsyncCallback(StreamingReadCallBack), null); 
      } 
      finally 
      { 
      } 
     } 
     private void StreamingReadCallBack(IAsyncResult asyncResult) 
     { 
      int read = stream.EndRead(asyncResult); 
     } 
    } 
} 

답변

0

것이 확인하십시오 :

  1. 유무를 그냥 자격 증명이 자신의 자리 표시 자 변경 도구 모음 메뉴 막대에서 스트리밍 모드를 활성화 했습니까?

    2. "자동 응답 사용"을 해제 했습니까?

희망 도움말.

+0

1 번했는데 "자동 응답 사용"옵션은 어디에서 찾을 수 있습니까? – TheOsiris

+0

방금 ​​발견했습니다. 기본적으로 사용 중지되어 있으며 변경하지 않았습니다. – TheOsiris

+0

여전히 문제를 해결하는 데 어려움이 있습니까? –

1

사람이 아직이 문제에 직면하는 경우 확실하지.

request.AllowReadStreamBuffering = false; 

이것은 최신 프레임 워크와 관련이 있습니다.