我正在写一个powershell脚本,它将每10分钟ping一次soap will服务,以保持它的热度和活力,因此性能将会提高。我们已经在IIS中尝试了许多技术,包括应用程序池、空闲、超时和只对wsdl发出http请求。但似乎我们必须向sql服务器发出真正的请求,否则90分钟的空闲时间会使它变慢以满足需求。
我必须构造一个相当复杂的搜索对象,以便能够进行智能搜索,从而保持servicelayer的缓存和热点。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>`我尝试使用新的WebServiceProxy,它在this example by powershellguy中工作得非常好。我构造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发布于 2012-09-21 18:04:46
我遵循了Christian (应该归功于他,但我不知道如何做到这一点)提供的链接,并使用了默认名称空间。因此,现在我不需要每次都重新启动powershell。也许有另一种解决方案可以在每次调用后终止fundSrvc对象。但我放弃了,转而使用默认的created long名称空间。
以下是有效的解决方案:
#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)发布于 2014-04-16 07:36:33
您最初的技术是正确的,您只需要在New-WebServiceProxy上包含-class参数即可。保持代码的其余部分不变。
昨天,我在使用PowerShell的had服务时遇到了这个问题。我还通过发现自动生成的名称空间让它工作,但这对我的喜好来说有点太老套了。
然后我找到了这里提到的解决方案:https://groups.google.com/d/msg/microsoft.public.windows.powershell/JWB5yueLtrg/k0zeUUxAkTMJ
$newWebService = New-WebServiceProxy -uri "http://<server>/webservices/services.php?wsdl" -NameSpace "Service" -Class "<classname>"https://stackoverflow.com/questions/12516512
复制相似问题