Protein database survey from F # 3.0

This practical Haskell example helped me install a trial version of Visual Studio 2012 to use providers like F #. However, I am completely obsessed with how to use it to solve this problem. There is an RCSB SOAP web service . I copied an example (which does not work because the web service API has changed) using the WSDL web service URL from RCSB:

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" 

But this leads to runtime failures with an error:

 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 

Also the SOAP web service is becoming obsolete in favor of a RESTful one . How can I use this from F # 3.0? What does the simplest working example look like?

+7
source share
1 answer

It seems that the BlastPDB operation BlastPDB overloaded, and the underlying generation code used by TypeProvider does not support it properly (it does not put “1” in the body name). See this answer for the same problem when using Svcutil directly with WCF: Svcutil generates an invalid client proxy, Apache AXIS web service, overload operations - this page shows that the Provider type uses svcutil internally .

AFAIK, you will not be able to access the REST service using the type provider, because REST services do not provide a schema (see this answer F # and REST apis type providers ). You may have to abandon the REST client library (see. NET Rest Client Frameworks here for some parameters) or run raw HTTP.

What does the simplest working example look like?

The following is a simple example to get the current list of PDB identifiers using the List of all current PDB REST API identifiers (I believe this is equivalent to the call you tried to use in the web service). You will need to add a link to 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 
+7
source

All Articles