2016-04-26 9 views
1

Softlayerのガイドラインに記載されているように、wsdlを使用してAPIメソッドをインポートしたC#アプリケーションがあります。 Container_Product_Order_Virtual_Guest_Upgrade構造体をProduct_Orderサービスに渡して、仮想ゲストを編集しています。Product_Order verifyOrder APIがguest_disksを追加するときに失敗する

guest_disksの商品価格IDを追加する場合を除いて、すべての機能が有効です。約6-7秒後に次の例外がスローされます。 "リクエストが中止されました:接続が予期せず閉じられました。 これは、verifyOrderメソッドとplaceOrderメソッドの両方で発生します。

ゲストディスクの値が有効であることを確認するために、Virtual_Guest :: getUpgradeItemPricesをチェックしました(VMの無効なitempriceIdsを渡すと、上記のような一般的な例外ではなく特定のエラー応答が返されます) 。

私はguest_disksを除くすべてのものをアップグレードできる理由を私に知らせるドキュメントの詳細は見つかりません。

EDIT:要求されたとして 剥奪コード:ここで

  SoftLayer_Virtual_Guest[] _VMtoEditList = new SoftLayer_Virtual_Guest[1] { -- Vm instance details are retrieved from SL according to the passed VM ID; }; 

      List<SoftLayer_Product_Item_Price> _itemPriceList = new List<SoftLayer_Product_Item_Price>(); 

      foreach (-- collection of properties to be upgraded) 
      { 
       SoftLayer_Product_Item_Category _category = new SoftLayer_Product_Item_Category(); 
       _category.categoryCode = -- retrieved from the collection on which I iterate (eg "guest_disk0", "ram", etc.); 


       SoftLayer_Product_Item_Price _itemPrice = new SoftLayer_Product_Item_Price(); 
       _itemPrice.id = -- the item priceID for the current item; 
       _itemPrice.idSpecified = true; 
       _itemPrice.categories = new SoftLayer_Product_Item_Category[1] { _category }; 

       _itemPriceList.Add(_itemPrice); 
      } 
      SoftLayer_Product_Item_Price[] _itemPricesArray = _itemPriceList.ToArray(); 

      SoftLayer_Container_Product_Order_Property _property1 = new SoftLayer_Container_Product_Order_Property(); 
      _property1.name = "NOTE_GENERAL"; 
      _property1.value = -- order's description; 

      SoftLayer_Container_Product_Order_Property _property2 = new SoftLayer_Container_Product_Order_Property(); 
      _property2.name = "MAINTENANCE_WINDOW"; 
      _property2.value = "now"; 

      // Build SoftLayer_Container_Product_Order_Property 
      SoftLayer_Container_Product_Order_Property[] properties = new SoftLayer_Container_Product_Order_Property[2] { _property1, _property2 }; 

      -- create container 
      SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade _upgradeContainer = new SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade(); 
      _upgradeContainer.virtualGuests = _VMtoEditList; 
      _upgradeContainer.prices = _itemPricesArray; 
      _upgradeContainer.properties = properties; 
      _upgradeContainer.packageId = 46; 
      _upgradeContainer.packageIdSpecified = true; 

      SoftLayer_Product_OrderService service = new SoftLayer_Product_OrderService(); 
      -- authentication structure is created here 

      SoftLayer_Container_Product_Order _verifiedOrder = service.verifyOrder(_upgradeContainer); 
      service.placeOrder(_verifiedOrder, false); 
+0

を助けている場合、あなたのコードを含めてもらえ教えてください? – Toxantron

答えて

0

下記参照働くアップグレードする例があります。あなたのコードでは、必要ではないpackageIdを追加しています。削除してからもう一度やり直してください。

また、Web参照を作成するときに、WSDL url(v3.1) のapiの最後のバージョンを使用してみてください。 https://api.softlayer.com/soap/v3.1/SoftLayer_Hardware_Server?wsdl

//----------------------------------------------------------------------- 
// <copyright file="PlaceOrderUpgrade.cs" company="Softlayer"> 
//  SoftLayer Technologies, Inc. 
// </copyright> 
// <license> 
// http://sldn.softlayer.com/article/License 
// </license> 
//----------------------------------------------------------------------- 
namespace VirtualGuests 
{ 
    using System; 
    using System.Collections.Generic; 
    class PlaceOrderUpgrade 
    { 
     /// <summary> 
     /// Order an upgrade for Virtual Guest 
     /// This script orders an upgrade for Virtual Guest, in this case we will upgrade the ram for a Virtual Guest, 
     /// It uses SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade container and SoftLayer_Product_Order::placeOrder 
     /// method for it. 
     /// For more information, review the following links: 
     /// </summary> 
     /// <manualPages> 
     /// http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder 
     /// http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade/ 
     /// http://sldn.softlayer.com/reference/services/SoftLayer_Product_Item_Price/ 
     /// </manualPages> 
     static void Main(String [] args) 
     { 
      // You SoftLayer username 
      string username = "set me"; 
      // Your SoftLayer API key.    
      string apiKey = "set me"; 
      // Define the virtual guest id to place an upgrade 
      int virtualId = 13115425; 
      // Creating a connection to the SoftLayer_Product_Order API service and    
      // bind our API username and key to it.   
      authenticate authenticate = new authenticate(); 
      authenticate.username = username; 
      authenticate.apiKey = apiKey; 

      SoftLayer_Product_OrderService orderService = new SoftLayer_Product_OrderService(); 
      orderService.authenticateValue = authenticate; 
      // Build a SoftLayer_Product_Item_Price objects with the ids from prices that you want to order. 
      // You can retrieve them with SoftLayer_Product_Package::getItemPrices method 
      int[] prices = { 
           1645 
          }; 
      List<SoftLayer_Product_Item_Price> pricesList = new List<SoftLayer_Product_Item_Price>(); 
      foreach (var price in prices) 
      { 
       SoftLayer_Product_Item_Price newPrice = new SoftLayer_Product_Item_Price(); 
       newPrice.id = price; 
       newPrice.idSpecified = true; 
       pricesList.Add(newPrice); 
      } 

      // Build SoftLayer_Container_Product_Order_Property object for the upgrade 
      SoftLayer_Container_Product_Order_Property property = new SoftLayer_Container_Product_Order_Property(); 
      property.name = "MAINTENANCE_WINDOW"; 
      property.value = "NOW"; 

      List<SoftLayer_Container_Product_Order_Property> propertyList = new List<SoftLayer_Container_Product_Order_Property>(); 
      propertyList.Add(property); 

      // Build SoftLayer_Virtual_Guest object with the id from vsi that you wish to place an upgrade 
      SoftLayer_Virtual_Guest virtualGuest = new SoftLayer_Virtual_Guest(); 
      virtualGuest.id = virtualId; 
      virtualGuest.idSpecified = true; 

      List<SoftLayer_Virtual_Guest> virtualGuests = new List<SoftLayer_Virtual_Guest>(); 
      virtualGuests.Add(virtualGuest); 

      // Build SoftLayer_Container_Product_Order object containing the information for the upgrade 
      //SoftLayer_Container_Product_Order orderTemplate = new SoftLayer_Container_Product_Order(); 
      SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade orderTemplate = new SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade(); 
      orderTemplate.containerIdentifier = "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade"; 
      orderTemplate.prices = pricesList.ToArray(); 
      orderTemplate.properties = propertyList.ToArray(); 
      orderTemplate.virtualGuests = virtualGuests.ToArray(); 
      try 
      { 
       // We will check the template for errors, we will use the verifyOrder() method for this. 
       // Replace it with placeOrder() method when you are ready to order. 
       SoftLayer_Container_Product_Order verifiedOrder = orderService.verifyOrder(orderTemplate); 
       Console.WriteLine("Order Verified!"); 
      } 
      catch (Exception e) 
      { 
       Console.WriteLine("Unable to place an upgrade for Virtual Guest: " + e.Message); 
      } 
     } 
    } 
} 

私はこれが

よろしく

+0

PackageIdを削除しても効果はありません。私の言う限りでは、あなたの例と私のコードとの間に違いはありません(私の場合、同じitempriceIdを持つ2つ以上のブロックデバイスを含むシナリオでは問題の可能性があります) 。明示的にv。3.1を含むために、私はSoftLayer APIを再インポートしようとします。 – basarab

関連する問題