2016-06-04 4 views
0

Ich versuche, wie unter MS Azure Java-Client-Code zu kodieren,MS Azure Java-Client-Code führt den Fehler

Configuration config = ManagementConfiguration.configure(
      new URI(uri), 
      subscriptionId, 
      keyStoreLocation, 
      keyStorePassword, 
     KeyStoreType.jks 
     ); 

    ManagementClient mclient = ManagementService.create(config); 

    System.out.println("Azure URI Path : " + mclient.getBaseUri()); 
    System.out.println("Azure API Version : " + mclient.getApiVersion()); 
    System.out.println("Azure의 Publishing ID : " + mclient.getCredentials().getSubscriptionId()); 

    LocationsListResponse lresp = mclient.getLocationsOperations().list(); **// this line throws error** 
    ArrayList<Location> locations = lresp.getLocations(); 
    System.out.println("Azure Regions : "); 
    for(int i=0; i<locations.size(); i++){ 
    System.out.println("\t" + locations.get(i).getName()); 
    } 

Der folgende Fehler ist wirft

Azure URI path : https://azure.microsoft.com/ 
Azure API verion : 2014-10-01 
Azure publishing ID : 92a65f9e-b6b6-4eaa-b5f7-e3180db19b62 


    [Fatal Error] :1:747: element type "n.length" next attribute ">" 또는 "/>"가 와야 합니다. 
    Exception in thread "main" com.microsoft.windowsazure.exception.ServiceException: <html> <head><script type="text/javascript">window.NREUM||(NREUM={});NREUM.info = {"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"b39980acba","applicationID":"10503464,11287305","transactionName":"Y1VSYkBRWEIEWhcICVoffWBxH2VYEVwgDghAQl9aXlVEHjVYBAQ=","queueTime":0,"applicationTime":29,"ttGuid":"7E0843DBD8B8C0A","agent":""}</script><script type="text/javascript> <style> 
      body { 
       background-color: #1a1a1a; 
      } 

      .tutorial-icon svg use { 
       stroke: #00abec; 
      } 
     </style> </head> <body> <svg class="svg-definition"><defs><symbol id="azure" viewBox="-1 -1 34 34"><path d="M19,17.4c-0.8,0-1.5,0.5-1.9,1.2H5.3v0c-2,0-3.6-1.6-3.6-3.6s1.6-3.6,3.6-3.6v0h0h0H7 

    <div class="column medium-9"> <ul class="linkList linkList-horizontal"> <li><a href="Feedbackhttps://feedback.azure.com/forums/34192--general-feedback">Feedback</a></li> <li><a href="Trademarkshttps://go.microsoft.com/fwlink/?LinkId=222682&clcid=0x409">Trademarks</a></li> <li><a href="Privacy">https://go.microsoft.com/fwlink/?LinkId=248681&clcid=0x409">Privacy &amp; Cookies</a></li> </ul> </div> <div class="column medium-3"> <div class="footer-copyright pull-right"> <a href="https://www.microsoft.com" class="logo-microsoft">Microsoft</a> <span>&copy; 2016 Microsoft</span> </div> </div> </div> </footer> <script type="text/javascript"> 
      function clearTextInput() { 
       document.getElementById('search-404').reset(); 


      ..... 
     </script> </body> </html> 
     at com.microsoft.windowsazure.exception.ServiceException.createFromXml(ServiceException.java:216) 
     at com.microsoft.windowsazure.management.LocationOperationsImpl.list(LocationOperationsImpl.java:162) 
     at com.aaa.azure.JavaClient.main(JavaClient.java:60) 

Java SDK ist integratede mit Eclipse mit Körperbau Pfad.

Irgendeine Idee? Ich brauche deine Informationen.

+0

Ich generierte JKS-Datei mit diesem Befehl, keytool.exe -importkeystore -srckeystore SampleRemoteAccessPrivate.pfx-destestkeystore. \ SampleRemoteAccessPrivate.jks -srcstoretype pkcs12 -desstotype JKS. Aber dieses Mal wird die Ausnahme wie folgt ausgelöst: Ausnahme im Thread "main" com.microsoft.windowsazure.exception.ServiceException: ForbiddenError: Der Server konnte die Anforderung nicht authentifizieren. –

Antwort

0

Nach den Fehlerinformationen scheint es, dass Sie die falsche URI https://azure.microsoft.com/ für die ManagementConfiguration verwendet haben.

Wie ich weiß, die URI für Azure Service-Management-Authentifizierung ist https://management.core.windows.net/

Weitere Informationen zu mit Azure Management-Bibliotheken für Java begonnen, bitte den Blog https://azure.microsoft.com/en-us/blog/getting-started-with-the-azure-java-management-libraries/ zu sehen.

+0

Vielen Dank für Ihre Antwort. Ich ändere die URL zu https://management.core.windows.net/ wie du gesagt hast. Der Code gibt jedoch die folgende Ausnahme aus: com.microsoft.windowsazure.exception.ServiceException: ForbiddenError: Der Server konnte die Anforderung nicht authentifizieren. Irgendeine Idee? –

+0

@JosephHwang Bitte sehen Sie meine Antwort für die anderen SO-Thread http://StackOverflow.com/Questions/33082328/azure-Java-SDK-ServiceException-forbiddenerror. Ich hoffe es hilft. Jedes Update, bitte zögern Sie nicht mich zu informieren. –

+0

Ich denke, ich muss lernen, wie ich meine JKS-Datei zu ms azure kann Einstellung exportieren. Ich versuche, mich mit https://management.core.windows.net/ mit der JKS-Schlüsseldatei in Verbindung zu setzen. aber die gleiche Ausnahme wird geworfen. Und ich habe 2 msdn accounts. Denkst du, dass dies die Probleme bringen kann, die ich habe? Und meine andere Frage ist, dass meine Java-Client-Quelle mit dem vorherigen Azure-Portal-Web gut funktioniert hat. , aber diese azurblaue Portalseite funktioniert die Codes nicht ... –

Verwandte Themen