Tôi đang viết một kịch bản PowerShell sẽ ping một dịch vụ web xà phòng cứ sau 10 phút để giữ cho nó nóng và sống để hiệu năng sẽ tăng lên. Chúng tôi đã thử nhiều kỹ thuật trong IIS với hồ bơi ứng dụng thời gian chờ nhàn rỗi và chỉ làm cho req http cho wsdl. Nhưng có vẻ như chúng tôi phải thực hiện yêu cầu thực sự đi xuống máy chủ sql khác một nhàn rỗi trong 90 phút sẽ làm cho nó để làm chậm cho các yêu cầu.Trong Powershell để tiêu thụ một SoapTypeType để giữ một dịch vụ xà phòng nóng
Tôi phải xây dựng một đối tượng tìm kiếm khá phức tạp để có thể thực hiện tìm kiếm thông minh sẽ giữ cho bộ nhớ cache được lưu trữ và nóng. Yêu cầu xà phòng nên trông như thế này:
<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>`
Tôi cố gắng sử dụng New-WebServiceProxy hoạt động rất thanh lịch trong this example by powershellguy. Tôi xây dựng my own Objects as this example from technet.
Mã PowerShell tôi đã cố gắng cho đến nay là thế này:
$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)
Các Thông báo lỗi không có ý nghĩa đối với tôi. âm thanh của nó như: 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
Bạn đã thử cách này chưa? http://www.sqlmusings.com/2012/02/04/resolving-ssrs-and-powershell-new-webserviceproxy-namespace-issue/ –
Không, nhưng bây giờ tôi sẽ gặp vấn đề này được mô tả trong liên kết của bạn nó có thể chạy một lần và sau đó tôi phải thay đổi không gian tên hoặc khởi động lại PowerShell. Nó hoạt động sau mỗi lần khởi động lại. Cảm ơn –
Đừng đặt không gian tên trong dấu ngoặc kép. '$ fundSrvc = New-WebServiceProxy -uri http: // myColdServer: 82/WSFund.svc? wsdl -NameSpace tcm' –