2012-09-20 7 views
6

Sto scrivendo uno script PowerShell che eseguirà un ping di un servizio web di sapone ogni 10 minuti per mantenerlo caldo e attivo, in modo che le prestazioni aumentino. Abbiamo provato numerose tecniche in IIS con il timeout di inattività del pool di applicazioni e facendo semplicemente http req per wsdl. Ma sembra che dobbiamo fare una richiesta reale che scende al server SQL altrimenti un inattivo per 90 minuti lo farà rallentare per i requisiti.In Powershell per consumare un complesso di saponeTipo per mantenere un servizio Soap hot

Devo costruire un oggetto di ricerca piuttosto complesso per poter effettuare una ricerca intelligente che manterrà il servicelayer memorizzato nella cache e caldo. Il Sapone richiesta dovrebbe essere simile a questo:

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

cerco di usare il New-WebServiceProxy che funzionano così elegantemente in this example by powershellguy. Costruisco my own Objects as this example from technet.

Il codice PowerShell ho provato finora è questo:

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

Messaggio L'errore non ha senso per me. I suoi suoni come: 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

Hai provato questo? http://www.sqlmusings.com/2012/02/04/resolving-ssrs-and-powershell-new-webserviceproxy-namespace-issue/ –

+0

No, ma ora mi sembra di avere questo problema che è descritto nel tuo link può essere eseguito una volta e quindi devo cambiare lo spazio dei nomi o riavviare PowerShell. Funziona dopo ogni riavvio. Grazie –

+0

Non mettere lo spazio dei nomi tra virgolette. '$ fundSrvc = New-WebServiceProxy -uri http: // myColdServer: 82/WSFund.svc? wsdl -NameSpace tcm' –

risposta

6

ho seguito il link che Christian (credito dovrebbe andare da lui, ma non so come fare) hanno dato e utilizzato lo spazio dei nomi predefinito. Quindi ora non ho bisogno di riavviare powershell ogni volta. Forse c'è un'altra soluzione per uccidere l'oggetto fundSrvc dopo ogni chiamata. Ma ho rinunciato e sono andato usando lo spazio dei nomi lungo pazzo creato di default.

ecco la soluzione che funziona:

#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

tua tecnica originale è di destra, è sufficiente includere anche il parametro di classe sui New-WebServiceProxy. Lascia il resto del codice così com'è.

Ho avuto questo problema esatto mentre lavoravo con un servizio web da PowerShell ieri. Ho anche funzionato scoprendo lo spazio dei nomi generato automaticamente, ma mi sembrava un po 'troppo hacky per i miei gusti.

Poi ho trovato la soluzione già detto qui: https://groups.google.com/d/msg/microsoft.public.windows.powershell/JWB5yueLtrg/k0zeUUxAkTMJ

+1

puoi aggiungere un breve esempio? –

Problemi correlati