Issues debugging New-WebServiceProxy

Consider the following code:

[string]$CurrentNameSpace = Get-RandomString -Length 8 $url = 'https://servername:443/RequestService/?wsdl' Try { $RequestService = New-WebServiceProxy -Uri $url -Namespace $currentNameSpace -Class WebServiceProxy -ErrorAction Stop } Catch [System.Net.WebException] { Write-Warning "Couldn't create Web-Service Proxy" return $Error[0].Exception.InnerException } $CurrentObjectType = $currentNameSpace + ".ActionType" $Arguments = New-Object $CurrentObjectType $CurrentObjectType = $currentNameSpace + ".SimpleActionType" $Arguments.action = New-Object $CurrentObjectType $Arguments.UserName = 'boundbylife' $Arguments.action.item = 'login' $Arguments.action.itemelementname = 'simple' $currentNameSpace $Arguments | Get-Member -Type Properties $RequestService.AgentLogin($Arguments) 

Returns the following:

kbyuyjyq TypeName: kbyuyjyq.ActionType Name MemberType Definition ---- ---------- ---------- action Property kbyuyjyq.simpleActionType action {get;set;} Id Property long Id {get;set;} IdSpecified Property bool IdSpecified {get;set;} lastCall Property kbyuyjyq.lastCallType lastCall {get;set;} station Property string station {get;set;} userName Property string userName {get;set;} Exception calling "AgentLogin" with "1" argument(s): "There was an error generating the XML document." At C:UsersboundbylifeDesktopSoapFunctions.ps1:107 char:3 + $RequestService.SimpleAction($Arguments) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : InvalidOperationException 

I have searched high and low on the internet, trying to find some way of debugging New-webserviceproxy, to figure out why the xml generation is failing. I can manually create a SOAP request and get back valid response, so I know it has to be in the cmdlet somewhere. At this point, I’m about ready to begin the blood sacrifices to Redmond.

submitted by /u/boundbylife
[link] [comments]

Leave a Reply