wcf - 使用Powershell2访问WCF Web服务

标签 wcf powershell powershell-2.0 wshttpbinding wcf-endpoint

我正在尝试编写一个cmdlet来访问我的WCF Web服务之一。

我一直在查看新的cmdlet:New-WebServiceProxy,但是它似乎真的能够使用ASMX Web服务。

我看过这篇文章;重点关注Powershell v1.0
我宁愿使用一种更好的方法(如果存在)。
http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!645.entry

从我使用此Web服务的其他.net应用程序中,这是我使用的那种配置。

 <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="819200" maxArrayLength="1638400" maxBytesPerRead="409600" maxNameTableCharCount="1638400" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://myServer/MyService/MyService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" contract="MyService.IMyService" name="WSHttpBinding_IMyService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

有人想劝我吗?

最佳答案

最终,您将要创建一个客户端代理对象,将其编译为.NET程序集,创建该代理并在PowerShell中对其编程。编写New-WebServiceProxy可以做到这一点。我很惊讶它只能与ASMX服务一起使用吗?也许对您不起作用,因为您没有在配置文件中定义MEX端点?请参阅此article on how to create a MEX endpoint,它将为您的Web服务启用代理生成。

关于wcf - 使用Powershell2访问WCF Web服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3151340/

相关文章:

c# - 如果两个应用程序使用不同的端点地址,它们能否共享相同的 WCF NetTcpBinding 端口?

.net - WCF线程-无响应的UI

iphone - SudzC iPhone 请求

powershell - Powershell:永久修改路径 “Requested registry access is not allowed.”

r - 如何使用R或PowerShell从文本文件中提取数据?

powershell - 我的 powershell 脚本在我预期的输出之前打印了 '1'。为什么?

powershell - 将脚本部署到目标环境后,如何保证不被修改?

wcf - svcutil、WSDL 和生成的接口(interface)不足以实现

email - 使用 "Send"参数调用 "1"的 PowerShell 异常 : "Failure sending mail."

powershell - Powershell:在html报告的顶部一次显示表头