【问题标题】:PowerShell WCF "The underlying connection was closed: An unexpected error occurred on a receive."PowerShell WCF“基础连接已关闭:接收时发生意外错误。”
【发布时间】:2021-01-13 16:58:54
【问题描述】:

我有一个调用 WCF Web 服务的 C#,它工作正常,所以我们知道 Web 服务工作正常并且可以调用它。

我现在尝试从 Powershell 调用相同的 WCF Web 服务,如下所示,并收到错误消息:

 "The underlying connection was closed: An unexpected error occurred on a 
receive."

Web 服务会进行一些日志记录,但在尝试 PowerShell 调用时我看不到任何日志。

# Create the WebSvcURL variable and pass the WSDL URL
$WebSvcURL= “http://localhost/DEMO/SetPassKey/SetPassKey_Logic_SetPassKeyWebService_SetPassKeyWCF.svc?wsdl“

#Create the Web Service Proxy Object

$serviceProxy = New-WebServiceProxy -Uri $WebSvcURL -UseDefaultCredential -Namespace "MyNamespace" -Class Program 

# Create Request Object
$req  = New-Object ("MyNamespace.SetPassKeyOrchWebRequest")  
$resp = New-Object ("MyNamespace.SetPassKeyOrchWebResponse")  

$req.NewPassKey = "TEST"    # <--- PUT YOUR NEW PASSWORD HERE 
$req   #  show the value is okay in the WebRequestobject 

$resp = $serviceProxy.SetPassKey($req) 

$resp  # show the response object 

我的相关问题是:Powershell New-WebServiceProxy - how to call WCF service。当我过去了,我开始收到上面的错误。

【问题讨论】:

    标签: wcf powershell-4.0


    【解决方案1】:

    我能够通过使用 WCF-BasicHTTP 绑定使其工作。

    如果有办法让它与 WCF-WSHTTP 一起工作,我仍然想知道。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      相关资源
      最近更新 更多