我正在尝试从Silverlight(4)将Rpc调用原型化为JBOSS网络服务器.我编写了代码,它正在一个控制台应用程序中工作 - 所以我知道Jboss正在响应Web请求.将它移植到silverlight 4,会导致问题:
let uri = new Uri(queryUrl)
// this is the line that hangs
let request : HttpWebRequest = downcast WebRequest.Create(uri)
request.Method <- httpMethod;
request.ContentType <- contentType
Run Code Online (Sandbox Code Playgroud)
它可能是一个沙盒问题,因为我的Silverlight是从我的文件系统提供的,而Uri是对本地主机的引用 - 尽管我甚至没有得到例外.思考?
谢谢
更新1
我创建了一个新项目并移植了我的代码,现在它正在工作; 关于F#Silverlight集成的东西必须是不稳定的.仍然会欣赏有关在旧模型中调试"悬挂"网页的想法...
更新2
let uri = Uri("http://localhost./portal/main?isSecure=IbongAdarnaNiFranciscoBalagtas")
// this WebRequest.Create works fine
let req : HttpWebRequest = downcast WebRequest.Create(uri)
let Login = async {
let uri = new Uri("http://localhost/portal/main?isSecure=IbongAdarnaNiFranciscoBalagtas")
// code hangs on this WebRequest.Create
let request : HttpWebRequest = downcast WebRequest.Create(uri)
return request
}
Login …Run Code Online (Sandbox Code Playgroud) 正如我所提到的,因为Silverlight HttpWebRequest.Create在异步块内部挂起,我只是创建了一组回调函数来实现相同的异步块.
登录过程需要两个步骤:
1)获取返回cookie的页面的请求2)表单发布到第二页,通过该cookie并执行身份验证
以下是src.无论是关于异步HttpWebRequest还是关于F#代码样式,欢迎和赞赏任何建议和讨论.
module File1
open System
open System.IO
open System.Net
open System.Text
open System.Security
open System.Runtime.Serialization
open System.Collections.Generic
open JsonData
open System.Net.Browser
open System.Threading
module rpc =
let mutable BASE_DNS = ""
let mutable requestId : int = 0
let getId() =
requestId <- requestId + 1
requestId.ToString()
module internal Helper =
///<Summary>
///Transfer data from Security.loginToRpc to Helper.FetchCookieCallback
///</Summary>
type LoginRequestRecord = {
Request : HttpWebRequest;
UserName : string;
Password : string;
AuthenticationUrl : …Run Code Online (Sandbox Code Playgroud) 我从Yahoo Finance中提取了历史报价,并试图将新报价(今天-周日的报价)添加到我的数据库中。但是,我不知道我应该将下拉过程安排在什么时候进行。应该在晚上的某个时间,但是任何人都知道何时可以从Yahoo Finance API获得新的(今天的)报价?
更新:我刚刚从以下位置找到更多信息:http : //marketmonksmusings.blogspot.com/2012/04/using-yahoo-free-eod-data.html
看起来它们是格林尼治标准时间12AM提供的,但最好稍后再下拉以获取更精确的报价。