【问题标题】:Accessing wcf web service with powershell2使用 powershell2 访问 wcf Web 服务
【发布时间】:2010-06-30 16:30:23
【问题描述】:

我正在尝试编写一个访问我的 wcf web 服务之一的 cmdlet。

我一直在研究新的 cmdlet:New-WebServiceProxy,但它似乎真的能够使用 ASMX 网络服务。

我看过这篇文章;主要围绕 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>

有人想给我建议吗?

【问题讨论】:

    标签: wcf powershell powershell-2.0 wshttpbinding wcf-endpoint


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多