2016-03-29 6 views
0

問題:私はAPIをヒットし、SoftLayer_Account#getVirtualGuestsのオブジェクトマスクを使用しようとしていますが、無視されているようです。ヘッダオブジェクトマスクを考慮していないSoftLayerアカウント

<SoftLayer_Virtual_GuestObjectMask> 
    <mask> 
    <datacenter xsi:nil="true" /> 
    <bandwidthAllotmentDetail><allocation xsi:nil="true" /></bandwidthAllotmentDetail> 
    </mask> 
</SoftLayer_Virtual_GuestObjectMask> 

でSoftLayer_Virtual_Guest.getObjectを呼び出す

は完璧に動作しますが、私は、ヘッダー

<SoftLayer_AccountObjectMask> 
    <mask> 
    <datacenter xsi:nil="true" /> 
    <bandwidthAllotmentDetail><allocation xsi:nil="true" /></bandwidthAllotmentDetail> 
    </mask> 
</SoftLayer_AccountObjectMask> 

とSoftLayer_Account.getVirtualGuestsを呼び出すとき、それはしていません:私が試した何

仕事、私はhttps://sldn.softlayer.com/article/object-masksの記事で見たように、SoftLayer_Account :: getHardwareを呼び出すときに、特定のタイプのルートプロパティを設定する必要があります。この例によると、SOAPを使って呼び出す方法を理解することはできません。

の例では、私は私の側に扱うことができるSoftLayer_Account.getVirtualGuestsためとオブジェクト・フィルタマスクオブジェクトを使用する方法で提供することができれば。

はありがとう

答えて

1

してください、SOAPリクエストを使用して、次の例を試してみてください。

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="http://api.service.softlayer.com/soap/v3/"> 
    <soapenv:Header> 
    <authenticate xsi:type="v3:authenticate"> 
     <username xsi:type="xsd:string">?</username> 
     <apiKey xsi:type="xsd:string">?</apiKey> 
    </authenticate> 
    <v3:SoftLayer_ObjectMask xsi:type="v3:SoftLayer_ObjectMask"> 
     <mask xsi:type="xsd:string">mask[id,datacenter,bandwidthAllotmentDetail]</mask> 
    </v3:SoftLayer_ObjectMask> 
    <SoftLayer_AccountObjectFilter xsi:type="v3:SoftLayer_AccountObjectFilter"/> 
    <SoftLayer_AccountObjectMask xsi:type="v3:SoftLayer_AccountObjectMask"> 
     <mask xsi:type="v3:SoftLayer_Account"/> 
    </SoftLayer_AccountObjectMask> 
    </soapenv:Header> 
    <soapenv:Body> 
    <v3:getVirtualGuests soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </soapenv:Body> 
</soapenv:Envelope> 

あなたはobject Masksobject Filtersを組み合わせたい場合は、以下を参照してください。

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="http://api.service.softlayer.com/soap/v3/"> 
    <soapenv:Header> 
    <authenticate xsi:type="v3:authenticate"> 
     <username xsi:type="xsd:string">?</username> 
     <apiKey xsi:type="xsd:string">?</apiKey> 
    </authenticate> 
    <v3:SoftLayer_ObjectMask xsi:type="v3:SoftLayer_ObjectMask"> 
     <mask xsi:type="xsd:string">filteredMask[id,datacenter,bandwidthAllotmentDetail]</mask> 
    </v3:SoftLayer_ObjectMask> 
    <v3:SoftLayer_AccountObjectFilter xsi:type="v3:SoftLayer_AccountObjectFilter"> 
     <virtualGuests> 
     <datacenter> 
      <name> 
      <operation>dal06</operation> 
      </name> 
     </datacenter> 
     </virtualGuests> 
    </v3:SoftLayer_AccountObjectFilter> 
    <SoftLayer_AccountObjectMask xsi:type="v3:SoftLayer_AccountObjectMask"> 
     <mask xsi:type="v3:SoftLayer_Account"/>  
    </SoftLayer_AccountObjectMask> 
    </soapenv:Header> 
    <soapenv:Body> 
    <v3:getVirtualGuests soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </soapenv:Body> 
</soapenv:Envelope> 
+0

mcruzさん、ありがとうございました、私が探していたものです...私は私の要求を変更しました。すべてが完璧に働いています。ちょうど質問です。ObjectFilterで 'virtualGuests'を使う必要があることをどうやって知っていますか?その背後にある論理は何ですか?ありがとうございました! –

+0

通常、 'Object Filters'を適用するとき、私たちは出発点を知るために' return values'が何であるかを知る必要があります。たとえば、[SoftLayer_Account :: getVirtualGuests](http://sldn.softlayer.com/reference/services/SoftLayer_Account/getVirtualGuests)を実行すると、[SoftLayer_Virtual_Guest](http://sldn.softlayer.com/)という配列が返されます。参照/データ型/ SoftLayer_Virtual_Guest)。次に、フィルタを使用するときにその値を操作したい場合は、この結果を処理する必要があります。 – mcruz

+0

'SoftLayer_Account :: getVirtualGuests'を実行する際に、' getVirtualGuests'メソッドから 'get'を削除して' filter'の最初の要素を知ることができます。他の例では、[SoftLayer_Account :: getHardware](http://sldn.softlayer.com/reference/services/SoftLayer_Account/getHardware)の最初の要素は 'hardware'です。これはルールではありませんが、私はそれに続くいくつかのケースを見ることができました。 – mcruz

0

私はgetVirtualGuestsこれはのbandwidthAllotmentDetail部分で自分のアカウント上のすべての仮想ゲストのJSONリストを返して

curl -s -g --user "$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY" "https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests.json?objectMask=mask[domain,bandwidthAllotmentDetail]" | python -m json.tool 
[ 
    { 
     "bandwidthAllotmentDetail": { 
      "allocationId": 5318597, 
      "bandwidthAllotmentId": 138442, 
      "effectiveDate": "2016-02-12T11:45:38-06:00", 
      "endEffectiveDate": null, 
      "id": 5479443, 
      "serviceProviderId": 1 
     }, 
     "domain": "tinylab.info" 
    }, 
    { 
     "bandwidthAllotmentDetail": { 
      "allocationId": 5569801, 
      "bandwidthAllotmentId": 138442, 
      "effectiveDate": "2016-03-22T10:17:46-06:00", 
      "endEffectiveDate": null, 
      "id": 5736289, 
      "serviceProviderId": 1 
     }, 
     "domain": "tinylayer.net" 
    }, 
    { 
     "bandwidthAllotmentDetail": { 
      "allocationId": 5468679, 
      "bandwidthAllotmentId": 138442, 
      "effectiveDate": "2016-03-04T00:00:00-06:00", 
      "endEffectiveDate": null, 
      "id": 5633115, 
      "serviceProviderId": 1 
     }, 
     "domain": "tinylab.info" 
    }, 
    { 
     "bandwidthAllotmentDetail": { 
      "allocationId": 5600063, 
      "bandwidthAllotmentId": 138442, 
      "effectiveDate": "2016-03-28T08:32:41-06:00", 
      "endEffectiveDate": null, 
      "id": 5767743, 
      "serviceProviderId": 1 
     }, 
     "domain": "tinylab.info" 
    } 
] 

呼び出すと、オブジェクトマスクを使用して、問題を見ていないですAPIレスポンス

+0

あなたのコメントのgreyhoundfortyをありがとう、私は必要SOAPの例であり、RESTの例ではありません。 –

関連する問題