2012-09-20 9 views
6

私はsoap webserviceをpingして10分ごとにpingしてパフォーマンスを向上させるためにpowershellスクリプトを作成しています。我々は、アプリケーションプールアイドルタイムアウトとwsdlのhttp reqを作成するだけで、IISで数多くのテクニックを試しました。しかし、それは私たちがSQLサーバに落ちる本当の要求をしなければならないと思われます。それ以外の場合、90分間アイドル状態にすると要件が遅くなります。PowershellでSoap複合型を消費してSoapサービスをホットに保つため

サービス客層をキャッシュして熱く保つスマートな検索を行うには、かなり複雑な検索オブジェクトを構築する必要があります。 SOAP要求は次のようになります。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fund="http://www.example.com/cmw/fff/fund" xmlns:tcm="http://www.example.com/cmw/fff/"> 
    <soapenv:Body> 
    <fund:Get> 
     <!--Optional:--> 
     <fund:inputDTO> 
      <fund:Fund> 
       <fund:Identity> 
       <fund:Isin>SE9900558666</fund:Isin> 
       <fund:FundBaseCurrencyId>SEK</fund:FundBaseCurrencyId> 
       </fund:Identity> 
      </fund:Fund> 
      <fund:InputContext> 
       <tcm:ExtChannelId>Channelman</tcm:ExtChannelId> 
       <tcm:ExtId>Rubberduck</tcm:ExtId> 
       <tcm:ExtPosReference>Rubberduck</tcm:ExtPosReference> 
       <tcm:ExtUser>Rubberduck</tcm:ExtUser> 
       <tcm:LanguageId>809</tcm:LanguageId> 
      </fund:InputContext> 
     </fund:inputDTO> 
    </fund:Get> 
    </soapenv:Body> 
</soapenv:Envelope>` 

私はthis example by powershellguyでとてもエレガント働く新しい-たWebServiceProxyを使用するようにしてください。私はmy own Objects as this example from technetを作っています。

私がこれまで試したPowerShellのコードはこれです:

$fundSrvc = New-WebServiceProxy -uri http://myColdServer:82/WSFund.svc?wsdl -NameSpace "tcm" 
# all the type are now defined since we called New-WebServiceProxy they are prefixed 
# with ns tcm 
[tcm.FundInput] $myFundGoofer = new-object tcm.FundInput 
[tcm.Fund] $myFund = new-object tcm.Fund 
[tcm.Context] $myInputContext = new-object tcm.Context 
[tcm.FundIdentity] $myFundIdentity = New-Object tcm.FundIdentity 
# Use these commands to get member of the objects you want to investigat 
# $myFundGoofer |Get-Member 
# $myFund |Get-Member 
# $myInputContext |Get-Member 
# $myFundIdentity |Get-Member 
$myFundIdentity.Isin="SE9900558666" 
$myFundIdentity.FundBaseCurrencyId="SEK" 
$myInputContext.ExtChannelId="ChannelMan" 
$myInputContext.ExtId="RubberDuck" 
$myInputContext.ExtPosReference="RubberDuck" 
$myInputContext.ExtUser="RubberDuck" 
$myInputContext.LanguageId="809" 
$myFund.Identity=$myFundIdentity 

$myFundGoofer.Fund = $myFund 
$myFundGoofer.InputContext = $myInputContext 

#Tada 
$fundSrvc.Get($myFundGoofer) 

エラーメッセージが私には意味がありません。以下のようなその音:Cannot convert the "tcm.FundInput" value of type "tcm.FundInput" to type "tcm.FundInput"

Cannot convert argument "0", with value: "tcm.FundInput", for "Get" to type "tcm.FundInput": "Cannot convert the "tcm.FundInput" value of type "tcm.FundInput" to type "tcm.FundInput"." 
At C:\scripts\Service-TestTCM6.ps1:31 char:14 
+ $fundSrvc.Get <<<< ($myFundGoofer) 
    + CategoryInfo   : NotSpecified: (:) [], MethodException 
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument 
+3

これを試しましたか? http://www.sqlmusings.com/2012/02/04/resolving-ssrs-and-powershell-new-webserviceproxy-namespace-issue/ –

+0

いいえ、しかし私は今あなたのリンクに記述されているこの問題があるようです一度実行すると、名前空間を変更したり、powershellを再起動したりする必要があります。再起動するたびに動作します。 Thanks –

+0

名前空間を引用符で囲まないでください。 '$ fundSrvc = New-WebServiceProxy -uri http:// myColdServer:82/WSFund.svc?wsdl -NameSpace tcm' –

答えて

6

私はクリスチャンが(クレジットは彼に行く必要がありますが、私はそれを行う方法がわからない)の代わりに、デフォルトの名前空間を与え、使用するリンクをたどっ。だから私は毎回powershellを再起動する必要はありません。おそらく、各呼び出しの後にfundSrvcオブジェクトを強制終了する別の解決策があります。しかし、私はあきらめて、既定の作成されたクレイジーな長い名前空間を使って行きました。ここで

が動作するソリューションです。

#note no -Namespace argument 
$fundSrvc = New-WebServiceProxy -uri "http://myColdServer/WSFund.svc?wsdl" 


#get autogenerated namespace 
$type = $fundSrvc.GetType().Namespace 
$myFundGooferDt = ($type + '.FundInput') 
$myFundDt = ($type + '.Fund') 
$myInputContextDt = ($type + '.Context') 
$myFundIdentityDt = ($type + '.FundIdentity') 
# Create the Objects needed 
$myFundGoofer = new-object ($myFundGooferDt) 
$myFund = new-object ($myFundDt) 
$myInputContext = new-object ($myInputContextDt) 
$myFundIdentity = New-Object $myFundIdentityDt 
# Assign values 
$myFundIdentity.Isin="SE9900558666" 
$myFundIdentity.FundBaseCurrencyId="SEK" 
$myInputContext.ExtChannelId="ChannelMan" 
$myInputContext.ExtId="RubberDuck" 
$myInputContext.ExtPosReference="RubberDuck" 
$myInputContext.ExtUser="RubberDuck" 
$myInputContext.LanguageId="809" 
$myFund.Identity=$myFundIdentity 

$myFundGoofer.Fund = $myFund 
$myFundGoofer.InputContext = $myInputContext 

#Tada 
$fundSrvc.Get($myFundGoofer) 
4

をあなたの元技術は右である、あなただけのも新たWebServiceProxyに-classパラメータを含める必要があります。残りのコードはそのままの状態にしておきます。

昨日、PowerShellのWebサービスで作業していたとき、私はこの問題を抱えていました。私はまた、自動生成された名前空間を発見することによってそれを働かせましたが、それは私の好みのためにちょっとハッキリです。

次に、ここに記載されている解決策が見つかりました:https://groups.google.com/d/msg/microsoft.public.windows.powershell/JWB5yueLtrg/k0zeUUxAkTMJ

+1

あなたは簡単な例を追加できますか? –

関連する問題