简体   繁体   English

通过HTTP代理的F#Odata服务类型提供程序

[英]F# Odata service type provider through http proxy

I want to use odata type provider but it causes next error while compiling: (407) proxy authentication required . 我想使用odata类型提供程序,但在编译时会导致下一个错误: (407) proxy authentication required There are no errors at design time. 在设计时没有错误。 Does anybody know how to set the proxy in type provider? 有人知道如何在类型提供程序中设置代理吗? Sample code: 样例代码:

open Microsoft.FSharp.Data.TypeProviders
type db = ODataService<"http://ebayodata.cloudapp.net/">
[<EntryPoint>]
     let main argv=
           let eBay = db.GetDataContext()
           0

This blog posting mentions some sample code which may cover proxies. 博客文章提到了一些可能包含代理的示例代码。

The Freebase type provider can be used with .NET 3.5, .NET 4.0, .NET 4.5, Silverlight and Portable programming. Freebase类型提供程序可以与.NET 3.5,.NET 4.0,.NET 4.5,Silverlight和Portable编程一起使用。 A proxy may be needed in some cases. 在某些情况下可能需要代理。 The projects in Tests\\ProjectsUsingTypeProvider.sln show some sample libraries for these different cases. Tests \\ ProjectsUsingTypeProvider.sln中的项目显示了针对这些不同情况的一些示例库。

You might wish to look at this file specifically as well. 您可能还希望专门查看此文件

Try to specify a default web proxy as follows: 尝试指定默认的Web代理,如下所示:

open System.Net // for WebProxy etc.
open Microsoft.FSharp.Data.TypeProviders

// put here actual proxy address
let proxy = new WebProxy("http://192.168.1.1:3128") :> IWebProxy
// put here your credentials if needed
proxy.Credentials <- NetworkCredential("proxy_user", "password")
// set up a default proxy
WebRequest.DefaultWebProxy <- proxy

// here the default proxy will be used
type db = ODataService<"http://ebayodata.cloudapp.net/">

Or you can try to use a proxy which was specified in IE as follows: 或者,您可以尝试使用IE中指定的代理,如下所示:

WebRequest.DefaultWebProxy <- WebRequest.GetSystemWebProxy()
WebRequest.DefaultWebProxy.Credentials <- CredentialCache.DefaultNetworkCredentials

If you have an error while compiling then this is probably because of F# compiler (Fsc.exe) can't connect to the proxy server. 如果编译时出错,则可能是由于F#编译器(Fsc.exe)无法连接到代理服务器。 You can fix this by modifying Fsc.exe.config , just add the following text under the configuration section: 您可以通过修改Fsc.exe.config来解决此Fsc.exe.config ,只需在configuration部分下添加以下文本:

  <system.net>
    <defaultProxy useDefaultCredentials="true" />    
  </system.net>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM