1

好的,我有一个奇怪的问题,我现在在 WSS 3.0 中有一个 SharePoint WebPart,它使用 VB.NET 和 HttpWebRequest 对象查询 Yahoo Traffic 的 REST 接口。然而,我不断从雅虎收到一条错误消息,说我未经授权,经过进一步检查,我注意到它正在将以下 URL 传递给雅虎: http ://local.yahooapis.com/MapsService/V1/trafficData?appid=&city =&状态=&半径=20

参数设置如下:

私有 _AppID 作为字符串

    <Personalizable(True), WebBrowsable(True), WebDisplayName("Yahoo App ID"), WebDescription("Yahoo Application ID")> _
    Public Property AppID() As String
        Get
            Return _AppID

        End Get
        Set(ByVal value As String)
            _AppID = value
        End Set
    End Property

    Private _City As String
    <Personalizable(True), WebBrowsable(True), WebDisplayName("City"), WebDescription("City")> _
    Public Property City() As String
        Get
            Return _City

        End Get
        Set(ByVal value As String)
            _City = value
        End Set
    End Property

    Private _State As String
    <Personalizable(True), WebBrowsable(True), WebDisplayName("State"), WebDescription("State")> _
    Public Property State() As String
        Get
            Return _State

        End Get
        Set(ByVal value As String)
            _State = value
        End Set
    End Property

    Private _radius As String = "-1"
    <Personalizable(True), WebBrowsable(True), WebDisplayName("Radius (in miles)"), WebDescription("Radius in Miles")> _
    Public Property Radius() As String
        Get
            If _radius = "-1" Then
                Return "20"
            Else
                Return _radius
            End If


        End Get
        Set(ByVal value As String)
            _radius = value
        End Set

结束属性

调用 REST 的代码是这样的:

        Dim Url As String = ""
        Try
            Dim aDoc As New d.DataSet
            Url = "http://local.yahooapis.com/MapsService/V1/trafficData?appid=" & Me.AppID & "&city=" & Me.City & "&state=" & Me.State & "&radius=" & Me.Radius
            Dim aRequest As n.HttpWebRequest = CType(n.HttpWebRequest.Create(Url), n.HttpWebRequest)
            Dim aResponse As n.HttpWebResponse
            aResponse = CType(aRequest.GetResponse(), n.HttpWebResponse)
            If aResponse.StatusCode <> Net.HttpStatusCode.OK Then
                Throw New Exception("Server Returned This Code" & aResponse.StatusCode.ToString() & aResponse.StatusDescription)
            End If
            aDoc.ReadXml(aResponse.GetResponseStream())
            Return aDoc
        Catch ex As Exception
            System.Diagnostics.EventLog.WriteEntry("YahooTrafficUtil", ex.Message & ex.StackTrace & Url)
            Dim aContext As System.Web.HttpContext = System.Web.HttpContext.Current
            aContext.Trace.Warn(ex.ToString() & ex.StackTrace)
            childException = ex
            Return Nothing

结束尝试

这是在我无法访问以进行调试的测试服务器上,但我的开发服务器检查正常,一切都通过,没问题。

AppId、City 和 State 参数是我的 SharePoint Web 部件中列出的参数,但出于某种原因,尽管我填充了这些 Web 部件,但它们通过空白。人群中的任何想法?谢谢!

4

2 回答 2

1

您是否尝试过不同的 WebPartStorage(Storage.Personal) [这默认为 Storage.Personal] 属性装饰?

我假设错误在于属性的存储而不是代码。

于 2009-01-27T20:17:28.587 回答
1

找到它,它实际上是 default.master 文件的一个愚蠢问题,我终于设法弄清楚如何从 SharePoint 获取堆栈转储,当它因“损坏的 Web 部件”网页而失败并追踪其真实来源时。感谢所有尝试过的人!

于 2009-01-27T22:00:16.163 回答