Invoke webservice - powershell 2.0

I am trying to invoke a vendor supplied webservice using powershell. The vendor supplied a working example, though it’s Java, not PowerShell. My requirements are that this be done in PowerShell instead.

Toward that goal, I believe I have been able to set things up correctly:

$URI = ‘’http://xxxx-xxxxxx.xx.xxxxxx.xxx:xxxx/arsys/WSDL/public/xxxx-xxxxxx.xx.xxxxxx.xxx:xxxx/HPD_IncidentInterface_Create_WS”
$svc = New-WebServiceProxy -Uri $URI

With this I can run things such as:

$svc | get-member –type method to identify the method I want to call.

Sadly the definition (again from the vendor, out of my hands) has 59 parameters, though most of them are optional. Of these parameters, the majority are string or Boolean types. Again, I do have the Java example and can confirm these are the parameters that are used.

In addition to the standard data types, there are four required parameters that are objects. From the method definition in PowerShell, I can see these are:

Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.Reported_SourceType
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.Service_TypeType
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.StatusType
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.Create_RequestType

I was able to instantiate these objects as follows:

$a = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.Reported_SourceType
$b = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.Service_TypeType
$c = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.StatusType
$d = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3PD_IncidentInterface_Create_WS.Create_RequestType

With this, I can display the default values of $a, $b, $c, $d, and have even been able to set (update) them with other suitable values.

With all of this in hand, I went to call the method for the webservice.

As I mentioned, the required parameters are strings, and the four object types, and not all of the arguments are required. To invoke the webservice, I again looked at the java example.

A condensed section looks like this:

			null,
			"IT Services",
			"Low",
			"3-Moderate/Limited",
			"Medium",
			null,
			null,
			null,
			ReportedSourceType.OTHER,
			null,

Here, the optional parameters are passed as null, the strings are passed with quotes, and the object is passed with a property

For my powershell translation (again, a comparable cross-section, not all 59 parameters) I used this:

$svc.CreateMethod($null, ‘IT Services’, ‘Low’,’3-Moderate/Limited’, ‘Medium’, $null, $null,$null,$a,$null)

Again, there are a few more strings, nulls, and the rest of the objects after this, but this is the basic call.

When I run this, I get the following error: Cannot find an overload for “CreateMethod” and the argument count: “59”.

I’m a little confused because I am indeed passing the necessary 59 parameters based on the method definition in PowerShell, I have also compared this to the working example in java and my arguments / parameters are the same.

Aside from the this, I am also wondering if I am passing the object types correctly. As I said, I instantiated them and when I display them, they return the correct value. Based on that, I was thinking I could just pass them as is for example: ,$a,

Any suggestions would be greatly appreciated!

Thanks,

Jeff Henke

I can get that same error with a 2 argument command. When this happens I rewrite it with some $variables between () and ways to avoid " and '.