2012-09-20 12 views
6

Performansı artıracak şekilde her 10 dakikada bir sabun web servisine ping yapacak bir powershell komut dosyası yazıyorum. IIS'de uygulama havuzu boşta kalma zaman aşımı ile çok sayıda teknik denedik ve sadece wsdl için http req yaptık. Fakat öyle görünüyor ki, sql sunucusuna inen gerçek bir istekte bulunmamız gerekiyor, 90 dakika boyunca bir rölanti, gereklilikleri yavaşlatıyor.Bir Soap hizmetini sıcak tutmak için bir Soap complexType kullanmak için Powershell'de

Servisörün önbelleğe alınmış ve sıcak kalmasını sağlayacak akıllı bir arama yapabilmek için oldukça karmaşık bir arama nesnesi oluşturmam gerekiyor. Sabun İsteği şuna benzer olmalı:

<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>` 

ben this example by powershellguy kadar zarif çalışmak Yeni-WebServiceProxy kullanmayı deneyin. my own Objects as this example from technet yapıyorum.

şimdiye kadar çalıştı Powershell kodu şudur:

$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) 

Hata Mesajı bana mantıklı değil. Onun sesler gibi: 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

Bunu denediniz mi? http://www.sqlmusings.com/2012/02/04/resolving-ssrs-and-powershell-new-webserviceproxy-namespace-issue/ –

+0

Hayır, ancak şimdi bağlantınızda açıklanan bu sorunla karşılaşıyorum. Bir kez çalıştırabilir ve sonra ad alanını değiştirmem veya powershell'i yeniden başlatmam gerekiyor. Her yeniden başlatmanın ardından çalışır. Teşekkür –

+0

İsim alanını tırnak içine koymayın. '$ fundSrvc = Yeni-WebServiceProxy -uri http: // myColdServer: 82/WSFund.svc? wsdl -NameSpace tcm' –

cevap

6

Christian o bağlantıyı takip (kredi ona gitmeli, ama bunun nasıl yapılacağını bilmiyorum) verdi ve yerine varsayılan ad kullanılır. Yani şimdi her zaman powershell yeniden başlatmaya gerek yok. Belki de her aramadan sonra fundSrvc nesnesini öldürmek için başka bir çözüm var. Ama pes ettim ve varsayılan oluşturulan çılgın uzun ad alanını kullanarak gittim. Sadece New-WebServiceProxy üzerinde -sınıfı parametresini eklemeniz gerekir,

#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

Orijinal teknik haklı: Burada

çalışır çözümdür. Kodunuzun geri kalanını olduğu gibi bırakın.

Dün bir PowerShell webservice ile çalışırken tam olarak bu sorunu yaşadım. Otomatik olarak oluşturulmuş ad alanını keşfederek de çalıştım, ama bu benim sevdiğim için biraz fazla hevesli hissettirdi.

Sonra çözüm burada sözü bulundu: https://groups.google.com/d/msg/microsoft.public.windows.powershell/JWB5yueLtrg/k0zeUUxAkTMJ

+1

lütfen kısa bir örnek ekleyebilirsiniz? –