none
WCF and stock quote services RRS feed

  • Question

  • Does anyone know of a service or website that supplies information on stocks (similar to what Yahoo finance shows in its website) but that would be accessible via a Windows Communication Foundation program.

    For a time I used http://www.webservicex.net/stockquote.asmx but they no longer respond either at the program level on as a website.

    I would need to access the service using Windows Communication Foundation.

    I use Vs2008 Professional and the C# language.

    Thanks.

    --John

    Monday, January 20, 2014 6:19 AM

Answers

  • You can access any public end point with code and the HttpWebRequest/Response classes:

    string theurl = "url of service here with query string params if used"
    
    System.Net.HttpWebRequest theRequest = (System.Net.HttpWebRequest)WebRequest.Create(theurl);
    System.Net.HttpWebResponse theResponse = (System.Net.HttpWebResponse)theRequest.GetResponse();
    
    using (System.IO.Stream str = theResponse.GetResponseStream())
    {
        //do whatever with the data
    }
    More details: http://msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx


    Bob - www.crowcoder.com


    Monday, January 20, 2014 1:15 PM
  • I think most any free web service will be unreliable. If you need reliability you may need to buy a subscription to Ameritrade or some other such service.

    Just don't get hung up on WCF. The whole point of web services (and I don't specifically mean Microsoft or aspnet) is that their implementation is irrelevant. You can code against them however you want.


    Bob - www.crowcoder.com

    Wednesday, January 22, 2014 2:28 PM

All replies

  • You can access any public end point with code and the HttpWebRequest/Response classes:

    string theurl = "url of service here with query string params if used"
    
    System.Net.HttpWebRequest theRequest = (System.Net.HttpWebRequest)WebRequest.Create(theurl);
    System.Net.HttpWebResponse theResponse = (System.Net.HttpWebResponse)theRequest.GetResponse();
    
    using (System.IO.Stream str = theResponse.GetResponseStream())
    {
        //do whatever with the data
    }
    More details: http://msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx


    Bob - www.crowcoder.com


    Monday, January 20, 2014 1:15 PM
  • Unfortuanately the webservice is no longer working, even within the browser.

    That is why I am looking for a new Wcf compatible web service for stock quotes.

    I do not want to "scrap" the data off a web page but access via a function call through Wcf.

    Again, any ideas would be appreciated.

    Thanks for your answer.

    --John

    Tuesday, January 21, 2014 5:25 AM
  • You miss my point. I'm not talking about scraping anything. You don't need a wcf based service. The client shouldn't care or have to know how a service is implemented. Your code makes a request and receives a response with the data. Here is a service that could be wcf based. http://www.webservicex.net/stockquote.asmx

    It uses soap, but if you look at the service description it also responds to GET and POST as any web service should.


    Bob - www.crowcoder.com

    Tuesday, January 21, 2014 10:42 AM
  • Thanks for the information.

    When I try the above website I receive the error below.

    This started about one week ago. Before that it did respond with information.

    Any suggestions would be appreciated.

    --John

    System.IO.IOException: There is not enough space on the disk.
    
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
       at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
       at System.IO.FileStream.Dispose(Boolean disposing)
       at System.IO.Stream.Close()
       at System.IO.StreamWriter.Dispose(Boolean disposing)
       at System.IO.TextWriter.Dispose()
       at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
       at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
       at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
       at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
       at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
       at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
       at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
       at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
       at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
       at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
       at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
       at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
       at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
    
    Wednesday, January 22, 2014 6:08 AM
  • I think most any free web service will be unreliable. If you need reliability you may need to buy a subscription to Ameritrade or some other such service.

    Just don't get hung up on WCF. The whole point of web services (and I don't specifically mean Microsoft or aspnet) is that their implementation is irrelevant. You can code against them however you want.


    Bob - www.crowcoder.com

    Wednesday, January 22, 2014 2:28 PM