I am trying to access a webservice in Powershell
Here is my code including the error message that I get
[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
Checked the username several times and confirmed with support that it's the right one and that the account is set up for it. Also: it works in a Visual Studio project
When getting the configuration of the webservice via svcutil it gives me the following configuration
<?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>
In the manual, they give the example for using the WSHttpBinding_ICoreWebService endpoint and that is also what works in a Visual Studio project.
What am I missing in my Powershell script?
Thank you!
Sandro
2014-05-22: updated to reflect latest script