2012-09-20 15 views
6

Piszę skrypt powershella, który będzie pingować serwis mydlany co 10 minut, aby utrzymać go na wysokim poziomie i utrzymać wysoką wydajność. Wypróbowaliśmy wiele technik w IIS z limitem czasu bezczynności puli aplikacji i po prostu tworzyliśmy http dla wsdl. Wygląda jednak na to, że musimy wykonać prawdziwą prośbę, która sprowadza się do serwera sql, bo jeszcze 90 minut wolnego czasu sprawi, że zwolni on do wymagań.W Powershell do spożywania Soap complexType, aby utrzymać usługę Soap na gorąco

Muszę skonstruować dość skomplikowany obiekt wyszukiwania, aby móc przeprowadzić inteligentne wyszukiwanie, które zapewni buforowanie i gorący serwer serwisowania. Żądanie Mydło powinien wyglądać następująco:

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

próbuję użyć Nowo WebServiceProxy które działają tak elegancko w this example by powershellguy. Buduję my own Objects as this example from technet.

Kod PowerShell próbowałem do tej pory to:

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

Komunikat o błędzie nie ma dla mnie sensu. Jej dźwięki jak: 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

Próbowałeś tego? http://www.sqlmusings.com/2012/02/04/resolving-ssrs-and-powershell-new-webserviceproxy-namespace-issue/ –

+0

Nie, ale teraz będę miał ten problem opisany w twoim linku może zostać uruchomiony raz, a następnie muszę zmienić obszar nazw lub ponownie uruchomić powłokę powershell. Działa po każdym restarcie. Dzięki –

+0

Nie umieszczaj przestrzeni nazw w cudzysłowach. '$ fundSrvc = New-WebServiceProxy -uri http: // myColdServer: 82/WSFund.svc? wsdl -NameSpace tcm' –

Odpowiedz

6

Śledziłem link że Christian (kredyt powinien udać się do niego, ale nie wiem, jak to zrobić) i dał stosowany zamiast domyślnej przestrzeni nazw. Więc teraz nie muszę ponownie uruchamiać powłoki powershell za każdym razem. Może istnieje inne rozwiązanie do zabicia obiektu fundSrvc po każdym wywołaniu. Ale zrezygnowałem i użyłem domyślnej, stworzonej zwariowanej długiej przestrzeni nazw.

Oto rozwiązanie, które działa:

#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

Oryginalna technika jest w porządku, po prostu trzeba również obejmować -class parametr na Nowym WebServiceProxy. Resztę kodu pozostaw tak jak jest.

Miałem ten problem podczas pracy z usługą webową z PowerShell wczoraj. Pracowałem też, odkrywając automatycznie generowany obszar nazw, ale to było trochę zbyt odurzające, jak na mój gust.

Następnie znalazłem rozwiązanie wymienione tutaj: https://groups.google.com/d/msg/microsoft.public.windows.powershell/JWB5yueLtrg/k0zeUUxAkTMJ

+1

czy możesz dodać krótki przykład? –