Error Calling Web Service Method

Hello all,

I’m trying to work with a vendor-supplied web service. I’m able to consume it easily enough from C#, but I’m struggling from powershell.

I’m by no means an expert with web services or the XML that defines them.


I can connect easily enough:

$docman = New-WebServiceProxy -Uri "http://server/webservices/DocumentManagement.svc?wsdl" -namespace ""
$auth = New-WebServiceProxy -Uri "http://server/webservices/Authentication.svc?wsdl" -namespace "";

and use some methods:

$token = $auth.AuthenticateUser("username", "password");

But when I’m trying to run an actual useful function as described:

$method = $docman | Get-Member -Name "AddVersion";
namespace AddVersion(int ID, namespace.Metadata metadata, namespace.Attachm
ent attach)

By calling something like:

$docman.AddVersion(69988, $metadata, $newattach);

I get:

Exception calling "AddVersion" with "3" argument(s): ""
At C:\Users\username\Documents\code\sqlpowershell.ps1:46 char:19
+ $docman.AddVersion <<<< (69988, $metadata, $newattach);
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

And here is the XML operation as defined:

- <wsdl:operation name="AddVersion">
  <wsdl:input wsaw:Action="urn:namespace/AddVersion" name="AddVersionRequest" message="tns:AddVersionRequest" /> 
  <wsdl:output wsaw:Action="urn:namespace/DocumentManagement/AddVersionResponse" name="AddVersionResponse" message="tns:AddVersionResponse" /> 

Any suggestions, or more information needed? Thank you.

My first question would have to be have you got the type correct for the parameters you are passing in?

Do you have a call that works in C# that doesn’t in PowerShell?