locked
How to access a webservice to windows 8 apps RRS feed

  • Question

  •  private async void GoButton_Click(object sender, RoutedEventArgs e)
            {
                WeatherSoapClient proxy = new WeatherSoapClient();
                WeatherReturn result = await proxy.GetCityWeatherByZIPAsync(inputZipCode.Text);
                ForecastReturn fr = await proxy.GetCityForecastByZIPAsync(inputZipCode.Text);
                Forecast[] f = fr.ForecastResult;
               if (result.Success)
                {
                    resultCityState.Text = String.Format("{0}, {1}", result.City, result.State);
                    resultDetails.Text = String.Format("\n conditions-{0}\n temperature-{1} ");

                }
                GetWeatherInformationResponse result1 = await proxy.GetWeatherInformationAsync();
                WeatherDescription[] r = result1.GetWeatherInformationResult;
                foreach (WeatherDescription d in r)
                    if (d.WeatherID == result.WeatherID)
                    {
                        image i = new image();
                        i.imageurl = d.PictureURL;
                        myimage.DataContext = i;
                        break;
                  }
            }
        }

      public class image
        {
            public string imageurl
            {
                get;
                set;
            }
        }

    xaml file

     <Grid>
            <Grid.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black"/>
                    <GradientStop Color="#FFD81337" Offset="1"/>
                </LinearGradientBrush>
            </Grid.Background>
            <StackPanel Orientation="Horizontal">
                <TextBlock HorizontalAlignment="Left" Height="68" TextWrapping="Wrap" Text="Use of Whether Web Service" VerticalAlignment="Top" Width="1306" FontFamily="Verdana" FontSize="48" Margin="38,20,0,0"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBox Name="inputZipCode" HorizontalAlignment="Left" Height="58" Margin="10,127,0,0" VerticalAlignment="Top" Width="477" FontFamily="Verdana" FontSize="36"/>
                <Button Name="GoButton" Content="Go" HorizontalAlignment="Left" Height="58" Margin="40,127,0,0" VerticalAlignment="Top" Width="136" FontFamily="Verdana" FontSize="36" Click="GoButton_Click"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock  HorizontalAlignment="Left" Height="27" Margin="38,90,0,0" TextWrapping="Wrap" Text="Enter the zip code below (U.S. only, e.g. 48653)" VerticalAlignment="Top" Width="494" FontFamily="Verdana" FontSize="20"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Image Name="myimage" HorizontalAlignment="Left" Height="200" Margin="10,190,0,0" VerticalAlignment="Top" Width="737" Source="{Binding imageurl}"/>
            </StackPanel>
            <StackPanel>
                <TextBlock x:Name="resultCityState" Height="100" HorizontalAlignment="Left" TextWrapping="Wrap" FontFamily="Verdana" Width="300" FontSize="36" Margin="15,400,0,0" />
            </StackPanel>
            <StackPanel Orientation="Vertical">
                <TextBlock x:Name="resultDetails" HorizontalAlignment="Left" Height="365" Margin="30,400,0,-39" TextWrapping="Wrap" VerticalAlignment="Top" Width="704" FontFamily="Verdana" FontSize="25"/>
            </StackPanel>
        </Grid>

    i will be getting the error

    The remote server returned an unexpected response: (407) Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  ).

                           

    amair

    Tuesday, September 10, 2013 7:00 AM

Answers

  • It sounds like you have a proxy in your environment.  Please see this:
    http://blogs.msdn.com/b/wsdevsol/archive/2012/10/25/how-to-accommodate-authenticating-proxies-in-net.aspx

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Anne Jing Monday, September 16, 2013 3:51 AM
    Tuesday, September 10, 2013 3:10 PM
    Moderator