在Powershell中使用Soap complexType使Soap服务保持热状态

在Powershell中使用Soap complexType使Soap服务保持热状态,soap,powershell,wsdl,Soap,Powershell,Wsdl,我正在编写一个powershell脚本,它将每10分钟ping一次soap Web服务,以使其保持热状态和活动状态,从而提高性能。我们在IIS中尝试了许多技术,包括应用程序池空闲超时和为wsdl生成http req。但是,我们似乎必须发出真正的请求,并将其发送到sql server,否则90分钟的空闲时间将使其变慢以满足需求 我必须构造一个相当复杂的搜索对象,以便能够进行智能搜索,使servicelayer保持高速缓存和热状态。Soap请求应如下所示: SE9900558666 瑞典克朗 通灵

我正在编写一个powershell脚本,它将每10分钟ping一次soap Web服务,以使其保持热状态和活动状态,从而提高性能。我们在IIS中尝试了许多技术,包括应用程序池空闲超时和为wsdl生成http req。但是,我们似乎必须发出真正的请求,并将其发送到sql server,否则90分钟的空闲时间将使其变慢以满足需求

我必须构造一个相当复杂的搜索对象,以便能够进行智能搜索,使servicelayer保持高速缓存和热状态。Soap请求应如下所示:


SE9900558666
瑞典克朗
通灵人
橡胶垫
橡胶垫
橡胶垫
809
`
我尝试使用新的WebServiceProxy,它在中工作得非常优雅。我构造

到目前为止,我尝试的powershell代码如下:

这个错误消息对我来说没有意义。其听起来像:
无法将类型为“tcm.FundInput”的“tcm.FundInput”值转换为类型为“tcm.FundInput”

无法将“Get”的值为“tcm.FundInput”的参数“0”转换为类型“tcm.FundInput”:“无法将类型为“tcm.FundInput”的“tcm.FundInput”值转换为类型“tcm.FundInput”。”
在C:\scripts\Service-TestTCM6.ps1:31 char:14

+$fundSrvc.Get我遵循了Christian(应该归功于他,但我不知道怎么做)给出的链接,并使用了默认名称空间。因此,现在我不需要每次都重新启动powershell。也许有另一种解决方案可以在每次调用后杀死fundSrvc对象。但我放弃了,继续使用默认创建的疯狂长名称空间

以下是有效的解决方案:

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

您最初的技术是正确的,您只需要在新的WebServiceProxy上包含-class参数。保持代码的其余部分不变

我昨天在使用PowerShell的Web服务时遇到了这个问题。我还通过发现自动生成的名称空间使它工作,但这对我来说有点太粗糙了

然后我找到了这里提到的解决方案:

$newWebService=newwebserviceproxy-uri”http:///webservices/services.php?wsdl-命名空间“服务”-类“”

您试过这个吗?不,但我现在会,我似乎有这个问题,这是在您的链接中描述的,它可以运行一次,然后我必须更改名称空间或重新启动powershell。每次重启后它都会工作。感谢不要将名称空间放在引号中<代码>$fundSrvc=新WebServiceProxy-urihttp://myColdServer:82/WSFund.svc?wsdl -命名空间tcm
您能添加一个简短的示例吗?
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
#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)
$newWebService = New-WebServiceProxy -uri "http://<server>/webservices/services.php?wsdl" -NameSpace "Service" -Class "<classname>"