I'm trying to call a web service method from my PowerShell script but it's failing. Here is the C# code:
public MyTable InsertRow(MyTable data)
{
var dataContext = new MyEntities();
dataContext.MyTables.AddObject(data);
dataContext.SaveChanges();
return data;
}
This is how I call it in PowerShell:
$uri = "http://localhost/MyWcfService/MyService.svc?wsdl"
$svc = New-WebServiceProxy -Uri $uri -UseDefaultCredential
$t = $svc.GetType().Namespace
$attributes = New-Object($t + ".MyTable")
$attributes.Name = "Project X"
$attributes.Comment = "This is a test"
$resp = $svc.InsertRow($attributes)
$resp
And this is the error that I get:
Cannot find an overload for "InsertRow" and the argument count: "1". At line:1 char:1 + $resp = $svc.InsertRow($attributes) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : MethodCountCouldNotFindBest
What am I doing wrong?
Update: This is the built-in .NET type when I call $attributes.GetType():
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True MyTable Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1WcfService_MyService_s...
$attributes.gettype()
? – Micky Balladelli