【发布时间】:2014-05-21 06:16:25
【问题描述】:
我正在尝试访问 Powershell 中的网络服务
这是我的代码,包括我收到的错误消息
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$proxy = New-WebServiceProxy -uri http://url/webService/platform/CoreWebService.svc?wdsl
$cert = new-object System.Security.Cryptography.X509Certificates.X509Certificate("test.cer")
$proxy.ClientCertificates.Add($cert)
$proxy.Credentials = Get-Credential
$proxy.WorkspaceList()
#Ausnahme beim Aufrufen von "WorkspaceList" mit 0 Argument(en): "Logon failed: unknown user name, wrong password or account disabled."
#In Zeile:2 Zeichen:5
#+ $proxy.WorkspaceList()
#+ ~~~~~~~~~~~~~~~~~~~~~~
# + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
# + FullyQualifiedErrorId : SoapException
多次检查用户名,并在支持人员的帮助下确认它是正确的,并且已为其设置了帐户。另外:它适用于 Visual Studio 项目
当通过 svcutil 获取 web 服务的配置时,它给了我以下配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICoreWebServiceBasic" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_ICoreWebService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
<binding name="WSHttpBinding_ICoreWebService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<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://url/webService/platform/CoreWebService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICoreWebService"
contract="ServiceReference1.ICoreWebService" name="WSHttpBinding_ICoreWebService">
<identity>
<certificate encodedValue="certificate string, which I copied into test.pfx, then imported into certificate store and exported as DER encoded cer file" />
</identity>
</endpoint>
<endpoint address="http://url/webService/platform/CoreWebService.svc/wauth"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICoreWebService1"
contract="ServiceReference1.ICoreWebService" name="WSHttpBinding_ICoreWebService1">
<identity>
<servicePrincipalName value="host/AMAZONA-1AGOCUI" />
</identity>
</endpoint>
<endpoint address="http://url/webService/platform/CoreWebService.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICoreWebServiceBasic"
contract="ServiceReference1.ICoreWebServiceBasic" name="BasicHttpBinding_ICoreWebServiceBasic" />
</client>
</system.serviceModel>
</configuration>
在手册中,他们给出了使用 WSHttpBinding_ICoreWebService 端点的示例,这也是在 Visual Studio 项目中的工作原理。
我的 Powershell 脚本中缺少什么?
谢谢!
桑德罗
2014-05-22:更新以反映最新脚本
【问题讨论】: