2011-08-17 6 views
1

私はPowerShellのに新たなんだと私は、次のWebサービスによって返されたオブジェクト(ファイルまたはデータベースに)保存する方法を把握しようとしている:Webサービスから返されたオブジェクトを保存する方法は?

$apiKey = "00000000-1111-2222-3333-444444444444" 
$userName = "12345678" 
$password = "SamplePassword" 

$URI  = "https://www.example.com/api/TestWS.TestService.svc?wsdl" 
$prox = New-WebServiceProxy -uri $URI -namespace WebServiceProxy 
$prox.chambersList 
$prox.chambersList($userName, $password, $apiKey, 0, $false, 0, $false) 

--------------------------------------------------------------------- 

MemberType   : Method 
OverloadDefinitions : {WebServiceProxy.chambersListOutputData, ijfah16c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null chambersList(string userName, string password, string apiKey, System.Nullable[int] pageNumber, bool pageNumberSpecified, System.Nullable[int] pageSize, bool pageSizeSpecified)} 
TypeNameOfValue  : System.Management.Automation.PSMethod 
Value    : WebServiceProxy.chambersListOutputData, ijfah16c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null chambersList(string userName, string password, string apiKey, System.Nullable[int] pageNumber, bool pageNumberSpecified, System.Nullable[int] pageSize, bool pageSizeSpecified) 
Name    : chambersList 
IsInstance   : True 

chambersList      : {797, 798, 799, 800...} 
pagesCount       : 92 
pagesCountSpecified    : True 
allElementsCount     : 918 
allElementsCountSpecified   : True 
pageNumber       : 1 
pageNumberSpecified    : True 
pageSize       : 10 
pageSizeSpecified     : True 
description      : OK 
code        : OK 
codeSpecified      : True 
information      : 

が、私は "と呼ばれるメソッドを呼び出すしたいと思いますチャンリスト "しかし、私はそれがどのように動作するのか理解するのに困っている。返されたオブジェクト(List?、Table?)をXML/CSV/TXT /データベースにエクスポートすることは可能ですか?どうやってやるの?

答えて

1

出力から、私はあなたから値を格納することができるはず集まるだろうあなたがPowershellで好きなことをすることができる変数へのメソッド:

$chambersListData = $prox.chambersList($userName, $password, $apiKey, 0, $false, 0, $false) 

#Just an example of using the data 
if ($chambersListData.allElementsCountSpecified) 
{ 
    $chambersListData.allElementsCount 
} 

$chambersListData.chambersList | Foreach-Object { 

    #do something with the elements 
} 

$chambersListData.chambersList | Export-Csv "myChambersList.csv" 

最後のものが有用かどうかを知るのは難しいですが、roomsの内容に依存します。

これが失敗した場合は、$chambersListData | Get-Memberを実行してください。

0

Get-command -verb export 

これらのコマンドを試してみてください。そして、各コマンドのために返さ:

Help export-.... 

一般的には、コマンドには、変数パイプます:

$prox.chambersList($userName, $password, $apiKey, 0, $false, 0, $false) | export-... 

かなりの数の方法があります。エクスポートするには、CSVとclixml(基本的にPowerShellオブジェクト)あなたが欲しいもののようなサウンド。 もちろん、後でやりたいことに依存しますか?

も、ここで詳細なヘルプをチェックアウト:

To see the examples, type: "get-help Export-CSV -examples". 
For more information, type: "get-help Export-CSV -detailed". 
For technical information, type: "get-help Export-CSV -full". 

と輸出-Clixmlコマンド用

To see the examples, type: "get-help Export-Clixml -examples". 
For more information, type: "get-help Export-Clixml -detailed". 
For technical information, type: "get-help Export-Clixml -full". 
関連する問題