2010-06-30 94 views
2

我試圖編寫一個訪問我的wcf web服務之一的cmdlet。使用powershell2訪問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> 

有人想告訴我嗎?

回答

2

最終,您將要創建一個客戶端代理對象,將其編譯爲.NET程序集,在PowerShell中創建該代理並對其進行編程。 New-WebServiceProxy被編寫爲允許你這樣做。我很驚訝,它只能對抗ASMX服務?也許它不適合你,因爲你的配置文件中沒有定義MEX端點?請參閱article on how to create a MEX endpoint這將啓用您的Web服務的代理生成。