Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services 从F#3.0查询蛋白质数据库_Web Services_Rest_Soap_F#_Type Providers - Fatal编程技术网

Web services 从F#3.0查询蛋白质数据库

Web services 从F#3.0查询蛋白质数据库,web-services,rest,soap,f#,type-providers,Web Services,Rest,Soap,F#,Type Providers,这鼓励我安装Visual Studio 2012试用版,以便使用F#type提供程序。然而,我完全困惑于如何使用它来解决这个问题。有一个问题。我使用RCSB中WSDL web服务的URL复制(由于web服务API已更改,因此无法工作): open Microsoft.FSharp.Data.TypeProviders type pdb = WsdlService<"http://www.rcsb.org/pdb/services/pdbws?wsdl"> do let w

这鼓励我安装Visual Studio 2012试用版,以便使用F#type提供程序。然而,我完全困惑于如何使用它来解决这个问题。有一个问题。我使用RCSB中WSDL web服务的URL复制(由于web服务API已更改,因此无法工作):

open Microsoft.FSharp.Data.TypeProviders

type pdb = WsdlService<"http://www.rcsb.org/pdb/services/pdbws?wsdl">

do
    let ws = pdb.Getpdbws()
    ws.getCurrentPdbIds()
    |> printfn "%A"
打开Microsoft.FSharp.Data.TypeProviders
类型pdb=WsdlService
做
设ws=pdb.Getpdbws()
ws.getCurrentPdbIds()
|>printfn“%A”
但这会在运行时崩溃,并出现以下错误:

Unhandled Exception: System.InvalidOperationException: RPC Message blastPDBRequest1 in operation blastPDB1 has an invalid body name blastPDB. It must be blastPDB1
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector.EnsureMessageInfos()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.EnsureMessageInfos()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.CreateFormatter()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
   at System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch)
   at System.ServiceModel.Description.DispatcherBuilder.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime)
   at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters)
   at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
   at System.ServiceModel.ChannelFactory.CreateFactory()
   at System.ServiceModel.ChannelFactory.OnOpening()
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ChannelFactory.EnsureOpened()
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at Program.pdb.ServiceTypes.PdbWebServiceClient.getCurrentPdbIds()
   at Program.pdb.ServiceTypes.SimpleDataContextTypes.PdbWebServiceClient.getCurrentPdbIds()
   at <StartupCode$ConsoleApplication2>.$Program.main@() in c:\users\jon\documents\visual studio 11\Projects\ConsoleApplication2\ConsoleApplication2\Program.fs: line 5
未处理的异常:System.InvalidOperationException:操作blastPDB1中的RPC消息blastPDBRequest1的正文名blastPDB无效。一定是PDB1
位于System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector.EnsureMessageInfo()处
位于System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.EnsureMessageInfo()处
位于System.ServiceModel.Description.XmlSerializerOperationBehavior.CreateFormatter()处
位于System.ServiceModel.Description.XmlSerializePropertyBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription,ClientOperation代理)
位于System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription契约、ClientRuntime代理、DispatcherRuntime调度)
位于System.ServiceModel.Description.DispatcherBuilder.ApplyClientBehavior(ServiceEndpoint ServiceEndpoint,ClientRuntime ClientRuntime)
位于System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint ServiceEndpoint、BindingParameterCollection和parameters)
位于System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint ServiceEndpoint,布尔值useActiveAutoClose)
在System.ServiceModel.ChannelFactory.CreateFactory()中
在System.ServiceModel.ChannelFactory.OnOpen()中
在System.ServiceModel.Channels.CommunicationObject.Open处(TimeSpan超时)
在System.ServiceModel.ChannelFactory.Resulted()中
位于System.ServiceModel.ChannelFactory`1.CreateChannel(端点地址,Uri通过)
位于System.ServiceModel.ChannelFactory`1.CreateChannel()
位于System.ServiceModel.ClientBase`1.CreateChannel()
位于System.ServiceModel.ClientBase`1.CreateChannelInternal()
在System.ServiceModel.ClientBase`1.get_Channel()中
在Program.pdb.ServiceTypes.PdbWebServiceClient.getCurrentPdbIds()中
位于Program.pdb.ServiceTypes.SimpleDataContextTypes.PdbWebServiceClient.getCurrentPdbIds()处
位于c:\users\jon\documents\visual studio 11\Projects\ConsoleApplication2\ConsoleApplication2\Program.fs中的.$Program.main@():第5行

此外,该计划也遭到了反对,取而代之的是。我如何使用F#3.0中的功能?最简单的工作示例是什么样子的?

看起来操作
BlastPDB
过载,TypeProvider使用的底层生成代码不能正确支持这一点(它没有在主体名称上加上“1”)。直接使用Svcutil时,请参见此问题的答案-此页面显示

恐怕您将无法使用类型提供程序访问REST服务,因为REST服务不提供模式(请参阅此答案)。您可能必须回退到REST客户端库(请参阅此处的一些选项)或执行原始HTTP

最简单的工作示例是什么样的

下面是一个使用RESTAPI获取当前PDB ID列表的简单示例(我相信这相当于您尝试使用web服务进行的调用)。您需要添加对System.Net.Http的引用

open System.Net.Http
open System.Threading.Tasks

[<EntryPoint>]
let main argv = 

    use httpClient = new HttpClient()
    let task = httpClient.GetStringAsync("http://www.rcsb.org/pdb/rest/getCurrent")
    printfn "%s" task.Result

    0
opensystem.Net.Http
开放系统.Threading.Tasks
[]
让主argv=
使用httpClient=newhttpclient()
让task=httpClient.GetStringAsync(“http://www.rcsb.org/pdb/rest/getCurrent")
printfn“%s”任务。结果
0

因此,类型提供程序的唯一目的是使用静态类型接口自动生成代码,而它生成的代码是错误的?WSDL类型提供程序的唯一目的是为WSDL web服务提供类型。F#团队已经尽可能重用了现有的工具(没有必要写两次)。不幸的是,您立即发现了他们使用的工具中的错误。我怀疑F#团队是否意识到这一点,但我建议您将其作为一个bug提出(可能有一个解决方法)。类型提供程序是在已知bug的情况下发布的,我不认为这是其中之一。W3基本配置文件禁止重载。WSDL可能有问题。