如何通过PowerShell通过LTM代理访问WCF SOAP服务?

时间:2015-04-16 22:04:44

标签: wcf powershell soap wsdl f5

我正在使用PowerShell访问WCF SOAP服务。这是所有hunky dory直接在WCF端点主机。我正在使用:

$request = New-WebServiceProxy -uri ${using:endpoint}"?wsdl" -class "MyService" -namespace "MS"

我有一台位于F5本地流量管理器(LTM)后面的新服务器。当我尝试同样的事情时,我收到错误,因为返回的WSDL包含指向服务器本身的链接,这是无法访问的,而不是LTM端点。

这导致:

The document was understood, but it could not be processed.
  - The WSDL document contains links that could not be resolved.
  - There was an error downloading 'http://myhost/MyService/MyService.svc?xsd=xsd0'.
  - Unable to connect to the remote server
  - No connection could be made because the target machine actively refused it 192.168.1.1:80
    + CategoryInfo          : InvalidOperation: (http://192.168.1...ervice.svc?wsdl:Uri) [New-WebServiceProxy], Invalid
   OperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.NewWebServiceProxy
    + PSComputerName        : localhost

我需要什么才能让LTM主机/ IP出现在WSDL中?我缺少服务的web.config中的一些设置吗?

1 个答案:

答案 0 :(得分:1)

将以下内容添加到您的web.config文件中:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <useRequestHeadersForMetadataAddress />

如果没有上述内容,WCF将从IIS中获取要呈现的URL。您还可以将主机标头添加到托管WCF的站点/应用程序的绑定中,它将使用它。

相关问题