Skip Navigation LinksHome > Support > Frequently Asked Questions > Development Tips

Tips

  •   How to choose between SOAP and HTTP to access our web services?
    • One the first and most important decisions you need to make when accessing our services is whether your will use the SOAP protocol or the HTTP protocol:
      1. Using HTTP requires little in terms of technology but can involve more programming. All you need is to make sure that your development environment lets you pull data from a url. If you can do that, you can use our services. You will receive an XML document that you will need to parse. This requires an XML parser and can be more arduous.
      2. Using SOAP requires that you have a SOAP toolkit but is much easier to do. Many SOAP toolkits exist today in all environments. Most of them are free. Many environments also support SOAP natively (at least in their latest versions). A SOAP toolkit will be able to automatically 'discover' and 'understand' our web services. And instead of parsing XML documents, you will be working with classes (or objects, or complex types). This will make your work easier. This is why we recommend you use SOAP.
  •   How to add a Web Reference of the Xignite Web Services in VisualStudio 2005?
    • If you are using Microsoft Visual Studio as your development environment, the first thing you need to do to consume our services is to add a web reference. Microsoft has made this process incredibly easy. Just follow these simple steps and you will be up and going in 2 minutes:
      1. Open an existing project or create a new one. It does not matter what type of project it is (console, windows, web...)
      2. Make sure the Solution Explorer window is open. If not, Use the View/Solution Explorer menu to open it.
      3. Locate the Reference entry in the Solution Explorer and right-click on it.
      4. Choose Add Web Reference from the pop-up menu. This will open the Add Web Reference window.
      5. Type in the address of the WSDL for the web service you want to use in the Address field.
      6. You may find it easier to have a browser window open pointing to the WSDL for the service and cut and paste the address in the Add Web Reference window. The web references for all our web services use the same syntax: http://www.xignite.com/xWebServiceName.asmx?WSDL. To find the WSDL of our web services, go to the web services product page. There are multiple ways to do that, such as through Main Menu -> Product Directory, Main Menu -> Product Pricing etc. When you are on our web service product page, there is a WSDL link on the left side. Click there to go to the WSDL page which shows you the path for that particular WSDL. Cut & Paste that value into the Add Web Reference window in Visual Studio
      7. Click on the Go button on the right of the input field. Visual Studio will then display the WSDL, and activate the Add Reference button as shown below. If you get an error at this stage (e.g. The HTML document does not contain Web service discovery information.), you probably did not type in the right WSDL address.


      8. You might want to change the name of the Web Reference. By default, Visual Studio will name it com.xignite.www. We do not find these default names too convenient. And we would recommend naming it to something else like RemoteRealTime, or RemoteQuotes based on the name of the service.
      9. Then click on the Add Reference button. Visual Studio will then close the window and dynamically generate a proxy class for the web service.
      10. You will now see a new entry under Web References which is a link to that proxy class.

      11. You are done! Your next step will be to write some code to invoke the service. We actually provide some sample code that you should be able to cut and paste and use right away. Simply go back to the Service page, choose an operation, and click on the Sample Code to check out VB or C# sample code for that operation. You should be able to cut and paste the code, compile and run it!
  •   How to add a Web Reference of the Xignite Web Services in Visual Studio 2008?
    • If you are using Microsoft Visual Studio 2008 as your development environment, you'll just need to make a couple of extra clicks first, then follow the steps listed above under How to add a Web Reference of the Xignite Web Services in VisualStudio 2005 starting from the Type in the address of the WSDL for the web service you want to use in the Address field section:
      1. Open an existing project or create a new one. It does not matter what type of project it is (console, windows, web...)
      2. Make sure the Solution Explorer window is open. If not, Use the View/Solution Explorer menu to open it.
      3. Locate Reference entry in the Solution Explorer and right-click on it.
      4. Choose Add Service Reference from the pop-up menu. This will open the Add Web Reference window.
      5. Click the Advanced button at the bottom left. This will open the Service Reference Settings window.

      6. Click the Add Web Reference button at the bottom left. This will open the Add Web Reference window.
      7. Follow the steps listed above under How to add a Web Reference of the Xignite Web Services in VisualStudio 2005 starting from the Type in the address of the WSDL for the web service you want to use in the Address field section.
  •   What are the data elements returned by the web services operations?
    • Return classes for Xignite Web Services share a set of standard elements that can help you work more effectively. All return classes inherit from a class called Common which is defined in the WSDL of all services. This class include the following elements:
      Outcome Is an enumeration indicating the outcome of the request. It will always be present and can therefore safely be tested. The possible values are:
      1. Success (0): The Request executed properly. Most return values should be populated.
      2. SystemError (1): An abnormal error occured when trying to execute this request, probably indicative of a bug with the service. Please contact our Support team if you run into such error. We track them on an ongoing basis and attempt to remove them as they occur.
      3. RequestError (2): Something was wrong with the request parameters, e.g. required parameters were missing or invalid, no data was found matching criteria...
      4. RegistrationError (3): You exceeded the number of requests allowed by your registration or subscription. See our Registration Policy section for details. Typical remedy include registering for the service if you have not done so or subscribing to the service.
      Message Is a string that contains an information message helping you further diagnose a problem indicated by Outcome. Message will is empty when Outcome is Success. Message will always contains some informational message if Outcome is not Success.
      Identity Is a string that indicates how your request was authenticated. This is helpful to diagnose registration problems. See the following section for details on authentication methods. Possible values are:
      1. IP : The Request was authenticated using the requesting computer's IP address.
      2. Cookie : The Request was authenticated using an HTTP Cookie. (See SOAP Requests Using HTTP Cookies for details).
      3. Header : The Request was authenticated using the SOAP Header.(See SOAP Requests Using SOAP Headers for details).
      4. Request : The Request was authenticated using a Request Parameter. (See Working with Web Services as XML Document for details).
      Delay Is a string indicating how long it took our servers to process your requests (in seconds). Not included in this delay are network transition and system initialization times.

      Dealing With Arrays
      Return classes can consist of a single instance or an array (collection) of instances (indicated as ArrayOf... in the WSDL). When the return class is a single instance, you simply need to test for Outcome, Message, Identity, or Delay in that instance. If the result is an array, you should always get at least one instance in the array. If an error occurred, it will be displayed in that first instance. It is therefore safe to test for the values above in the first instance of the return array.

      Message and Outcome in SubClasses
      Some web services provide message information in a subclass of the return class. For instance, if you use the GetQuotes operation, you will get an array of quotes as a result. If the system is unable to retrieve some, but not all quotes, the system will return a specific message for that quote instance.
  •   Does your web service request require authentication?
    • Yes, Xignite services and operations require authentication. Only Operations whose usage is Unlimited require no authentication. Xignite supports four methods to authenticate your requests:

      IP Address This method relies on the IP of the computer making the request. If your computer uses a static IP, it is the simplest approach. Xignite enables you to register an unlimited number of IPs. You should not use this method if you computer uses a Dynamic IP address. Your IP address is likely to be dynamic if:
      1. You use a dial-up ISP service.
      2. Your computer is not used as a server in your firm. You should check with your system administrator to be sure.
      Soap Header

      This is the best method to use when using SOAP.

      This method relies on additional parameters passed along with your SOAP request to authenticate it. You should choose this method if your IP address is Dynamic and if you plan to use the SOAP protocol.

      Check the SOAP Requests Using SOAP Headers tip for details.

      HTTP Cookie

      This method mainly applies to request you place using your browser. When you register for a service, we install a cookie on your machine. Subsequent requests you place use that cookie for authentication.

      You can manually add or remove a cookie from your machine using the AddCookie and DeleteCookie operations.

      You can programatically pass along with your GET or POST request to authenticate it. You should choose this method if your IP address is Dynamic and if you plan to use the POST or GET protocols. You can use this method if you use the SOAP protocol, but you will need to manually add the cookie to your request, check the SOAP Requests Using HTTP Cookies section for details.

      Request Parameter

      This is the best method to use when using HTTP.

      This method relies on an additional parameter ("Header_Username" populated with the email address provided during registration) passed along with your GET or POST request to authenticate it. You should choose this method if your IP address is Dynamic and if you plan to use the POST or GET protocols. This method is most helpful if you like to manipulate web services as XML Document, check the Working with Web Services as XML Document section for details.


      For HTTP requests, our web services try to authenticate your requests in the following order:
      1. Request
      2. Cookie
      3. IP
      For SOAP requests, our web services try to authenticate your requests in the following order:
      1. SOAP
      2. Request
      3. Cookie
      4. IP

      If the system fails to authenticate your request, it will assume that you are unregistered for the web service and it will apply unregistered users restrictions. This will not necessary mean that your request will fail. Some operations allow a limited number of free requests to unregistered users.
  •   How to authenticate SOAP Requests using SOAP Header (VB.Net, C#, Apache Axis, PHP 5.0, NuSoap PHP, Flex)?
    • If your computer uses a Dynamic IP address and you plan to use SOAP to invoke operation, you should add a SOAP header to your request to help authenticate it. You may also choose this approach to authenticate your requests even if your IP address is static. You only need to make sure you use the same email address when you registered.

      All Xignite operations accept a SOAP Header simply named Header. This Header accepts three optional parameters.
      1. Username holds your system Username, which is the email address you provided when registering for the service.
      2. Password is currently unused.
      3. Tracer is used for tracing your SOAP requests. See the Troubleshooting section for details.

      To authenticate your request using SOAP headers, you need only provide a value for the Username parameter. The technique to add a soap header to your SOAP request will depend on your development toolkit.

      Adding Soap Headers to a SOAP Request in VisualStudio.Net

      When you add a web reference to an Xignite service using VisualStudio.Net, the proxy class that is automatically generated recognizes the optional SOAP Header and makes it easy for you to provide a value:

      VB

      'RemoteQuotes is the web reference to the XigniteQuotes service
      'objRemoteQuote is an instance of the service proxy
      Dim objRemoteQuote as New RemoteQuotes.XigniteQuotes()
      'create an instance of the header
      Dim objHeader As New RemoteQuotes.Header()
      'assign your username
      objHeader.Username = "me@myfirm.com"
      'assign the header to the service proxy
      objRemoteQuote.HeaderValue = objHeader
      'you can then call any method
      Dim objExtendedQuote as RemoteQuotes.ExtendedQuote = objRemoteQuote.GetQuote("MSFT")

      C#

      ///RemoteQuotes is the web reference to the XigniteQuotes service
      ///objRemoteQuote is an instance of the service proxy
      RemoteQuotes.XigniteQuotes objRemoteQuote = new RemoteQuotes.XigniteQuotes();
      ///create an instance of the header
      RemoteQuotes.Header objHeader = new RemoteQuotes.Header();
      ///assign your username
      objHeader.Username = "me@myfirm.com";
      ///assign the header to the service proxy
      objRemoteQuote.HeaderValue = objHeader;
      ///you can then call any method
      RemoteQuotes.ExtendedQuote objExtendedQuote = objRemoteQuote.GetQuote("msft");

      Adding Soap Headers to a SOAP Request in Apache Axis 1.4

      In Axis 1.4, you must manually create the SOAP header and assign its values.

      //Instantiate the service
      XigniteRealTime objRealTimeService = new XigniteRealTimeLocator();
      XigniteRealTimeSoap objRealTimePort = objRealTimeService.getXigniteRealTimeSoap();
      org.apache.axis.client.Stub s = (Stub) objRealTimePort;
      //Instantiate the objects that will let you build the SOAP Header
      javax.xml.parsers.DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
      //Create a new document
      org.w3c.dom.Document doc = builder.newDocument();
      //Create the Header (named "Header")
      org.w3c.dom.Element elem = doc.createElementNS("http://www.xignite.com/services/", "Header");
      //Create an element called "Username"
      org.w3c.dom.Element elem2 = doc.createElementNS("http://www.xignite.com/services/","Username");
      //Assign your email address (me@myfirm.com) to the Username element
      elem2.appendChild(doc.createTextNode("me@myfirm.com"));
      //Add the "Username" element to the Header
      elem.appendChild(elem2);
      //Create an element called "Password"
      elem2 = doc.createElementNS("http://www.xignite.com/services/", "Password");
      //leave the password blank (currently unused)
      elem2.appendChild(doc.createTextNode("password"));
      //Add the "Password" element to the Header
      elem.appendChild(elem2);
      //Create an element called "Trace"
      elem2 = doc.createElementNS("http://www.xignite.com/services/","Tracer");
      //leave the password blank (unless you want to activate tracing)
      elem2.appendChild(doc.createTextNode(""));
      //Add the "Trace" element to the Header
      elem.appendChild(elem2);
      //Create a SOAP header from the document
      SOAPHeaderElement she = new SOAPHeaderElement(elem);
      //Assign the SOAP Header to the stub
      s.setHeader(she);

      Adding Soap Headers to a SOAP Request in Apache Axis2

      In Axis2, you must manually create the SOAP header and assign its values. Depending on the service and operation you are calling the header class name may not be "Header1", modify the code accordingly. Note that to generate JAX-RPC code with Axis2 (recommended), you must use the wsld2java code generation tool. The most common code generation usage would be: wsdl2java -uri "http://www.xignite.com/xQuotes.asmx?WSDL" -s -ap. More info is available on the Axis2 site.

      //Instantiate the service
      XigniteQuotesXigniteQuotesSoapStub stub = new XigniteQuotesXigniteQuotesSoapStub();
      //Instantiate the objects that will let you build the SOAP Header
      Header1 header = new Header1();
      //Create the Header
      Header h = new Header();
      //Assign your email address (me@myfirm.com) to the Username element
      h.setUsername("me@myfirm.com");
      //Set the password
      h.setPassword("");
      //Set the SOAP header
      header.setHeader(h);
      //Create the arguments needed for the call
      GetQuotes getQuotes = new GetQuotes();
      getQuotes.setSymbol("msft,aapl");
      //Make the call with the arguments and the header
      GetQuotesResponse response = stub.GetQuotes(getQuotes, header);

      Adding Soap Headers to a SOAP Request in Apache Axis2 with JAX-WS

      Axis2 also supports Web Service calls over JAX-WS, a newer implementation, and code utilizing the JAX-WS API may not be entirely compatible with ASP.NET 2.0 Web Services, due to their use of RPC/Encoded and lack of a JAX-WS binding for this. With this in mind, developing JAX-WS clients to consume Xignite Web Services is not recommended or supported, in that there is no workaround for marshalling SOAP objects which have no JAX-WS binding. Background information on the differences between JAX-WS and JAX-RPC is available from IBM developerWorks' Web Services site.

      However, if you must use this API, some Xignite Web Services will work with JAX-WS with some additional modification. Axis2 requires JAX-WS client code be generated using the wsimport generation tool, and authenticating against Xignite Web Services will require the addition of the -XadditionalHeaders switch, so that the command will look something like:

      wsimport -XadditionalHeaders http://www.xignite.com?xIndexComponents.asmx?WSDL

      The generated code can be used similarly to the Axis2/JAX-RPC method:

      //Instantiate the service
      XigniteIndexComponents service = new XigniteIndexComponents();
      //Create the SOAP stub service
      XigniteIndexComponentsSoap soap = service.getXigniteIndexComponentsSoap();
      //Create the Header
      Header header = new ObjectFactory().createHeader();
      //Assign your email address (me@myfirm.com) to the Username element
      header.setUsername("me@myfirm.com");
      //Set the password
      header.setPassword("");
      //Make the call with the arguments and the header
      Components components = soap.getIndexComponents("^GSPC", IdentifierTypes.SYMBOL, header);

      PHP 5

      // define the SOAP client using the url for the service
      $xignite_header = new SoapHeader('http://www.xignite.com/services/',
      'Header', array("Username" => "me@myfirm.com",
      "Password" => "YourPassword",
      "Tracer" => ""));
      $wsdl = new soapclient('http://www.xignite.com/xCurrencies.asmx?WSDL');
      // attach SOAP header
      $wsdl->__setSoapHeaders(array($xignite_header));
      // call the service: pass the parameters and name of the operation
      $input_params = array('From' => "USD", 'To' => "PKR");
      $result = $wsdl->GetRealTimeCrossRate($input_params);
      // assess the results
      if ($wsdl->fault) {
      echo '<h2>Fault</h2><pre>';
      print_r($result);
      echo '<pre>';
      }
      else {
      // display the results
      echo '<h2>Result</h2><pre>';
      // this function exposes the complete structure of the return class
      print_r($result);
      echo '</pre>';
      }

      NuSoap PHP

      $UserName = 'me@myfirm.com';
      $Password = '';
      $wsdl = 'http://www.xignite.com/xHistorical.asmx?wsdl';
      // create a new client, using the WSDL
      $client = new soapclient($wsdl, true);
      if($err = $client->getError())
      echo '<h2>Constructor Error</h2><pre>'. $err. '</pre>';
      // create the parameters for the service
      $param = array(
      'Identifier' => "MSFT",
      'IdentifierType' => "Symbol",
      'EndDate' => '05/23/2007',
      'PeriodType' => "Day",
      'Periods' => "2");
      // SOAP Header is required for this service
      $header = '<Header xmlns="http://www.xignite.com/services/">'.
      '<Username>'. $UserName. '</Username>'.
      '<Password>'. $Password. '</Password>'.
      '<Tracer>'.'</Tracer></Header>';
      // Cannot use proxy because SOAP Header is required
      $result = $client->call('GetHistoricalQuotesAsOf', array('parameters' => $param),
      'http://www.xignite.com/services/',
      'http://www.xignite.com/services/GetHistoricalQuotesAsOf',
      $header);

      Flex 2/SOAP

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
      creationComplete="onCreationComplete()">
         <mx:Script>
         <![CDATA[
         import mx.rpc.events.ResultEvent;
         import mx.controls.Alert;

         //When the application starts up we will call the web service
         private function onCreationComplete() : void
         {
            //Create the Header with the right namespace.
              Add the Username with your username as the value

            xigniteQuotes.addSimpleHeader("Header", "http://www.xignite.com/services/",
               "Username","me@myfirm.com");
            //Make the call to GetQuickQuotes
            xigniteQuotes.GetQuickQuotes.send( "MSFT" );
         }
         ]]>
         </mx:Script>
         <!-- Setup the WebService and point to the WSDL-->
         <mx:WebService id="xigniteQuotes" wsdl="http://www.xignite.com/xQuotes.asmx?WSDL">       <!-- Pick the operation you want to call, and the resultFormat -->
            <mx:operation name="GetQuickQuotes" resultFormat="e4x"
            fault="mx.controls.Alert.show(event.fault.faultString)"
            result="mx.controls.Alert.show(event.result.toString())">
               <mx:request>
                  <Symbol></Symbol>
               </mx:request>
            </mx:operation>
         </mx:WebService>
      </mx:Application>

  •   How to authenticate SOAP Requests using Cookies?
    • While cookies work well with HTTP Get and POST requests, they will not automatically be passed when doing SOAP requests in most development toolkits. You should check with your development toolkit to ensure that the cookies are sent with your request. If you are using Visual Studio.Net, following are some instructions you can use to do this easily.

      Adding HTTP Cookies to a SOAP Request in VisualStudio.Net

      You simply need to add a routine to the web service proxy created by VS.Net and call that routine prior to invoking an operation.
      1. Add a Web Reference to the web service you want to use by right-clicking on the References (or Web References if you have one) folder in the Solution Explorer window.
      2. Enter the address of the web service WSDL you want to use, e.g. http://www.xignite.com/xquotes.asmx?WSDL. Click on the Add Reference button.
      3. Locate the web reference you created for the XigniteQuote web service in the Solution Explorer window.
      4. Rename the Web Reference you just created by right-clicking on it and choosing Rename in the menu. For instance, you could use RemoteQuotes as the new name.
      5. Using the Visual Studio.Net main menu, do "File", "Open", and "File". This will open an "Open File" window.
      6. Click on the Web Reference directory. This is where VS.Net stores the proxy classes created automatically.
      7. Click on the Folder for that Web Reference, e.g. RemoteQuotes.
      8. In that folder you should find 3 files:
        1. a .map file
        2. a .wsdl file which is a local copy of the web service WSDL
        3. a .vb or .cs file which is the code generated by VS.Net for the proxy
      9. Open the .vb or .cs file.
      10. In the file, you will see the following code:

      11. VB

        Public Class RemoteQuotes
        Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

        '<remarks/>
        Public Sub New()
        MyBase.New()
        Me.Url = "http://www.xignite.com/xquotes.asmx"
        End Sub

        C#

        public class XigniteQuotes : System.Web.Services.Protocols.SoapHttpClientProtocol {

        ///<remarks/>
        public XigniteQuotes() {
        MyBase.New()
        this.Url = "http://www.xignite.com/xquotes.asmx";
        }
      12. Under that section, add a new routine called AddCookie(). This routine creates a cookie and adds it to the cookie collection of the proxy class. Replace the youremailaddress value with your email address.

      13. VB

        Public Sub AddCookie()
        Dim objCookie As New System.Net.Cookie("xigniteemail","youremailaddress", "/", "www.xignite.com")
        Dim objCookieContainer As New System.Net.CookieContainer(1)
        objCookieContainer.Add(objCookie)
        Me.CookieContainer = objCookieContainer
        End Sub

        C#

        public void AddCookie()
        {
        System.Net.Cookie objCookie = new System.Net.Cookie("xigniteemail","youremailaddress", "/", "www.xignite.com");
        System.Net.CookieContainer objCookieContainer = new System.Net.CookieContainer(1);
        objCookieContainer.Add(objCookie);
        this.CookieContainer = objCookieContainer;
        }
      14. Then you code must call this method prior to each time a web service method is called. It is not sufficient to call AddCookie() once.

      15. VB

        Dim objRemoteQuote as New RemoteQuotes.XigniteQuotes()
        'Add this prior to each method call
        objRemoteQuote.AddCookie()
        Dim objExtendedQuote as RemoteQuotes.ExtendedQuote = objRemoteQuote.GetQuote("MSFT")

        C#

        RemoteQuotes.XigniteQuotes objRemoteQuote = new RemoteQuotes.XigniteQuotes();
        ///Add this prior to each method call
        objRemoteQuote.AddCookie();
        RemoteQuotes.ExtendedQuote objExtendedQuote = objRemoteQuote.GetQuote("msft");
  •   How to authenticate SOAP Requests using HTTP Cookies?
    • Doing POST and GET requests using HTTP cookies is pretty straightforward. When you register for a service or operation, the system will create a cookie on your computer. Any POST or GET request you place later on should automatically forward the cookie to the our servers.

      If you delete your cookie or want to add the cookie on another machine, you can easily recreate it by logon to our website using the same email address that you had registered with us.
  •   How to call the web services using HTTP POST or GET?
    • Some developers prefer working with Web Services as XML Documents (HTTP) rather than instances of objects (SOAP). The advantage of such approach is that one can readily apply an XSL Stylesheet to the result of the request to reformat the output. This can be done directly in an ASPX page without much coding.

      There are two things to consider when using this approach:
      1. If you used a Dynamic IP registration, you should place your requests using the GET protocol and qualify them with the optional 'Header_Username' parameter populated with the email address you provided at registration. This is needed because SOAP Headers and Cookies will not work with this approach. If you are using Static IP registration, this step is not required. If you use POST, you must simply add the 'Header_Username=YourEmailAddress' to the parameter pairs you post.
      2. You should be aware that the resulting document is defined with "http://www.xignite.com/services" as its default namespace. Therefore all XML manipulations of that document will require that namespace to be defined and all queries to be prefixed accordingly.


      Following is some sample code illustrating this method in Visual Studio.Net:

      VB

      'create an xml document instance
      Dim objDocument as New System.Xml.XmlDocument()
      'load the document by providing a url to the service fully
      'qualified with all required parameters of the service
      'if you use Dynamic Ip Registration, you must also provide the 'Header_Username'
      'parameter populated with the email address you provided at registration
      objDocument.Load("http://www.xignite.com/xquotes.asmx/GetMarketSummary? _ Header_Username=youremail@yourcompany.com")
      'you can now manipulate the content of the document
      'first create a namespace manager instance
      Dim objNameSpaceManager As New System.Xml.XmlNamespaceManager(objDocument.NameTable)
      'then add the Xignite default namespace to it. The prefix name 'xi' is arbitrary
      objNameSpaceManager.AddNamespace("xi", "http://www.xignite.com/services/")
      'any Xpath query must use the namespace manager
      'all elements and attribute references must be prefixed
      'the following query queries the 'Index' rows from the document.
      Dim objNodeList As System.Xml.XmlNodeList = objDocument.DocumentElement.SelectNodes _ ("descendant::xi:Index", objNameSpaceManager)
      'we can now process the nodes
      Dim objNode as System.Xml.XmlNode
      For Each objNode In objNodeList
          'we qualify the query again
          Console.WriteLine(objNode.SelectSingleNode("child::xi:Name", objNameSpaceManager).InnerText)
      Next
  •   How to force the calls to use HTTP Get instead of HTTP Post?
    • Some proxy servers block HTTPPOSTcalls. To generate the client side code to use HttpGet instead of HttpPost, one can use the wsdl.exe generation tool with the following command:



      wsdl /l:CS /protocol:HttpGet < URL to the WSDL >


      The drawback of doing it this way is that a lot of helpful information will be lost, e.g., the inputs to services are always strings and not enums. There is also no built in Header and Username by generating the code this way, so the calls one make would need to be authenticated through IP for this to really work.
      Besides using the wsdl.exe generation tool, another option is to just use the WebRequest class to fecth the service output and deal with parsing the XML by hand.
  •   How to apply an XSL stylesheet to the result of a Web service
    • If you used the method described in the previous topic, a natural next step would be to apply an XSL stylesheet directly to the result of the Web Service. Once you have loaded the result of a web service as XML document (as described in the previous FAQ topic), applying a stylesheet is simple. You still have to worry about manipulating the document using the proper namespace. For instance, the following code will apply a stylesheet directly to a document as it is loaded in an XML WebControl for display in a web page.

      VB

      'create an xml document instance
      Dim objDocument as New System.Xml.XmlDocument()
      'load the document by providing a url to the service fully
      'qualified with all required parameters of the service
      'if you use Dynamic Ip Registration, you must also provide the 'Header_Username'
      'parameter populated with the email address you provided at registration
      objDocument.Load("http://www.xignite.com/xquotes.asmx/GetMarketSummary? _ Header_Username=youremail@yourcompany.com")
      'you can now manipulate display the content of the document after applying a stylesheet
      'first create a XSL transform instance
      Dim objStylesheet As New System.Xml.Xsl.XslTransform()
      'then load your stylesheet
      objStylesheet.Load("c:/thelocationofyourstylesheet.xslt")
      'let's create an XML webcontrol
      Dim objXMLControl As New System.Web.UI.WebControls.Xml()
      'let's apply the document and stylesheet to it
      objXMLControl.Document = objDocument
      objXMLControl.Transform = objStylesheet
      'you could then add this control to your page.

      Let's find out how the stylesheet looks like. Remember that the output of the Web Service will look something like this (here we use the GetMarketSummary operation as an example). To process this document properly, the stylesheet must:
      1. Declare the default namespace of the document (http://www.xignite.com/services/)
      2. Qualify all xPath query with this namespace
      Click here to see a sample stylesheet and here to see the result of that stylesheet applied to the service.
  •   How to decode images?
    • Some operations return images as an array of bytes (System.Byte()) while other return a URL pointing to a temporary copy of the image stored on our servers. Pointing to a URL may be the best approach for a web application. If your application is local, or if you want to make a local copy of the image, you should use the binary approach.

      Following is some sample VB code that shows how to turn the array of bytes into an image:

      'here we are using the XigniteSurvey service as an example
      'RemoteSurvey is the web reference to the XigniteSurvey service
      Dim objWebService as New RemoteSurvey.XigniteSurvey()
      Dim objResult As RemoteSurvey.SurveyChartBinary = objWebService.RespondWithChartBinary(... your parameters here...)
      'this command creates an image based on a stream converted from the array of bytes
      Dim objImage As New System.Drawing.Bitmap(New System.IO.MemoryStream(objResult.Chart.ByteArray))
      'you can save then it locally or use it in your application
      objImage.Save("c:\image.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

      Java

      For instructions on how to decode a byte array into a bitmap image using java, check this article.
  •   How to create a reference assembly to a web service when using ASPX?
    • If you are planning to use one of our web services in an ASP.Net application and if you are not planning to use the code-behind technique, you will need to create a reference assembly to the service. To do this, follow these simple steps:
      1. First, generate the proxy source file using the wsdl.exe utility at a Visual Studio .Net Command Prompt (here we are using the XigniteRealTime service as an example)
      2. C:\>wsdl.exe /language:VB http:://www.xignite.com/xRealTime.asmx?WSDL
      3. This will generate a file called XigniteRealTime.vb (or .cs if you used the CS language option). You can then compile the VB file into an Assembly.
      4. C:\>vbc.exe /t:library /r:System.dll /r:System.Web.dll /r:System.Web.Services.dll
        /r:System.Xml.dll XigniteRealTime.vb
      5. This will generate a file called XigniteRealTime.dll that you can add to your VisualStudio project and must copy to your ASP.NET project /bin directory.
      6. You can then consume the service using code similar to that provided under the Sample Code in the This Operation menu.
  •   How to turn off HTTP chunking in Apache Axis2?
    • Apache Axis2 by default allow HTTP content to be chunked. This causes the SOAP request to be broken up into chunks and caused our webservice to return last cached results disregarding symbol, username...etc. So a request of IDX could return results for RUT.

      Following is some sample code that shows how to turn off HTTP chunking before calling our web services:

      XigniteRealTimeStub stub = new XigniteRealTimeStub("http://www.xignite.com/xRealTime.asmx");
      // Begin - code to turn off HTTP chunking
      Options options = stub._getServiceClient().getOptions();
      options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
      stub._getServiceClient().setOptions( options );
      // End - code to turn off HTTP chunking
      GetRealQuote quote = new GetRealQuote();
      quote.setExchange(ECNTypes.INET);
      quote.setSymbol(symbol);
      Header3 header = new Header3();
      Header h = new Header();
      h.setUsername("yourusername");
      h.setPassword("yourpassword");
      // Note: if you set the tracer with a different value, the results will not be cached properly.
      h.setTracer("");
      header.setHeader(h);
      GetRealQuoteResponse response = stub.GetRealQuote(quote, header);
      System.out.println(response.getGetRealQuoteResult().getMessage());
      System.out.println(response.getGetRealQuoteResult().getLast() + " : " +
          response.getGetRealQuoteResult().getName() + " : " +
          response.getGetRealQuoteResult().getSymbol());
 




Hostname: XIGNITE30