好的,我有一个奇怪的问题,我现在在 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 部件,但它们通过空白。人群中的任何想法?谢谢!