API > API

Connecting to the APIs

Passi necessari per la configurazione di Visual Studio 2010
  1. Aprire Visual Studio e fare click nel Menu su "File" > "New" > "Project..." (Ctrl + Shift + N).

  2. Selezionare "ConsoleApplication" tra i vari template e cliccare su "OK".

  3. Andare nel pannello "Solution Explorer" e con il tasto destro fare click sulla cartella del progetto. Ha questo punto fare click con il tasto sinistro su "Add Service Reference".

  4. Nel finestra che si apre inserire nel campo "Address" l'URL di accesso alle API "https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc?wsdl" e fate click su "Go". Selezionare sotto la voce "Services" il servizio che appare, modificare eventualmente il "Namespace" e fare click su "OK".

  5. Ripetere altre due volte i punti 3, 4 e 5 per aggiungere gli altri servizi necessari modificando il campo "Address" con i seguenti url:
    "https://api.dc1.computing.cloud.it/WsCommon/v2.9/WsCommon.svc?wsdl"
    "https://api.dc1.computing.cloud.it/WsLicense/v2.9/WsLicense.svc?wsdl"
  6. Modificare nel file app.config il parametro maxReceivedMessageSize come evidenziato qui sotto.
     
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.serviceModel>
     <bindings>
      <basicHttpBinding>
       <binding name="BasicHttpsEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
         maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="TransportWithMessageCredential">
         <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
         <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
       </binding>
      </basicHttpBinding>
      <wsHttpBinding>
       <binding name="HttpsEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
        transactionFlow="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
         maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <reliableSession ordered="true" inactivityTimeout="00:10:00"
         enabled="false" />
         <security mode="TransportWithMessageCredential">
          <transport clientCredentialType="None" proxyCredentialType="None"
           realm="" />
          <message clientCredentialType="UserName" negotiateServiceCredential="true"
           algorithmSuite="Default" establishSecurityContext="false" />
          </security>
         </binding>
        </wsHttpBinding>
       </bindings>
      <client>
       <endpoint address="https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc"
        binding="wsHttpBinding" bindingConfiguration="HttpsEndpoint"
        contract="ServiceWsEndUser.IWsEndUser" name="HttpsEndpoint" />
       <endpoint address="https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/soap11"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpsEndpoint"
        contract="ServiceWsEndUser.IWsEndUser" name="BasicHttpsEndpoint" />
       <endpoint address="https://api.dc1.computing.cloud.it/WsCommon/v2.9/WsCommon.svc"
        binding="wsHttpBinding" bindingConfiguration="HttpsEndpoint"
        contract="ServiceWsCommon.IWsCommon" name="HttpsEndpoint1" />
       <endpoint address="https://api.dc1.computing.cloud.it/WsLicense/v2.9/WsLicense.svc"
        binding="wsHttpBinding" bindingConfiguration="HttpsEndpoint"
        contract="ServiceWsLicense.IWsLicense" name="HttpsEndpoint2" />
      </client>
     </system.serviceModel>
      
    A questo punto non resta che provare il collegamento alle API modificando il metodo Main del file Program.cs.
     
            using ArubaCloud.ServiceWsCommon;
            using ArubaCloud.ServiceWsEndUser;
            using ArubaCloud.ServiceWsLicense;
            namespace ConsoleApplication1
            {
                class Program
                {
                    static void Main(string[] args)
                    {
     
                       //crea un nuovo oggetto di tipo WsEndUserClient 
                       using (WsEndUserClient client = new WsEndUserClient("HttpsEndpoint"))
                       {
    		        //crea un nuovo oggetto di tipo WsCommonClient
    		 	using (WsCommonClient client = new WsCommonClient())
    			{
    			}
    
    			//crea un nuovo oggetto di tipo WsLicenseClient
    
    			using (WsLicenseClient client = new WsLicenseClient())
    	        }
            }
        } 
    }
    
Passi necessari per la configurazione di NetBeans 7
  1. Aprire NetBeans e fare click nel Menu su "File" > "New" > "New Project..." (Ctrl + Maiusc + N).

  2. Selezionare "Java" > "Java Application" tra i vari template e cliccare su "Next >".

  3. Modificare il "Project Name" in ArubaCloud e cliccare su "Finish".

  4. Andare nel pannello "Projects" e con il tasto destro fare click sulla cartella del progetto. A questo punto fare click con il tasto sinistro su "New" > "Web Service Client...".

  5. Nel finestra che si apre inserire nel campo "WSDL URL": l'url di accesso alle API "https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc?wsdl" lasciare vuoto il campo "Package", selezionare la voce "Generate Dispatch code" e fare click su "Finish". Successivamente confermare accettando i certificati che verranno scaricati.

  6. Andare nel pannello Projects aprire la cartella "Web Service References" e con il tasto destro fate click sull'oggetto "WsEndUser". A questo punto fare click con il tasto sinistro su "Edit Web Service Attributes...".

  7. Nel finestra che si apre nella sezione "HttpsEndPoint Binding" > "Security" selezionare la voce "Use developement defaults", a questo punto NetBeans chiederà di sostituire le librerie di axis con quelle di metro, confermare cliccando su "OK".

  8. Successivamente deselezionare la voce "Use developement defaults" e cancellare "Username" e "Password".

  9. Fare click sul "Tab" > "Wsimport Options" e aggiungere una Option con questi valori Option=binding Value=simple-binding.xjb, confermare cliccando su "OK".

  10. Andare nella cartella d'installazione di netbeans per creare un file con nome "simple-binding.xjb". Copiare al suo interno quanto segue:
     
    <jxb:bindings version="1.0"
        xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <jxb:globalBindings generateElementProperty="false" />
    </jxb:bindings>
  11. Ripetere altre due volte i punti 4, 5, 6 e 9 per aggiungere gli altri servizi necessari modificando il campo "WSDL URL" con i seguenti url: "https://api.dc1.computing.cloud.it/WsCommon/v2.9/WsCommon.svc?wsdl" e "https://api.dc1.computing.cloud.it/WsLicense/v2.9/WsLicense.svc?wsdl".
  12. Ricompilare l'intero progetto e a questo punto non resta che provare il collegamento alle API modificando il metodo Main del file ArubaCloud.java.
     
            package arubacloud;
    
            import https.api_computing_cloud_it.wscommon.v2.IWsCommon;
            import https.api_computing_cloud_it.wscommon.v2.WsCommon;
            import https.api_computing_cloud_it.wsenduser.v2.IWsEndUser;
            import https.api_computing_cloud_it.wsenduser.v2.WsEndUser;
            import https.api_computing_cloud_it.wslicense.v2.IWsLicense;
            import https.api_computing_cloud_it.wslicense.v2.WsLicense;
    
            public class ArubaCloud {
    
                public static void main(String[] args) {
     
                    try
                    {	
                        IWsEndUser iWsEndUser = new WsEndUser().getHttpsEndpoint();
    			        IWsCommon iWsCommon = new WsCommon().getHttpsEndpoint();
    			        IWsLicense iWsLicense = new WsLicense().getHttpsEndpoint();
    
                    } catch (Exception e) 
                    { 
                        System.out.println(e); 
                    } 
                } 
            }
            

Versione
API v2.9 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc?wsdl
API v2.9 URL: https://api.dc1.computing.cloud.it/WsCommon/v2.9/WsCommon.svc?wsdl
API v2.9 URL: https://api.dc1.computing.cloud.it/WsLicense/v2.9/WsLicense.svc?wsdl