How to get XML response from PowerShell New-WebServiceProxy

So the great thing PowerShell is that it automatically generates strongly typed classes when used New-WebServiceProxy

with WSDL

. I can talk to the web service just fine, but I really want the XML response not to be a response object (strongly typed).

Following code example:

$proxy = New-WebServiceProxy -Uri http://internal/EmployeeDetails?WSDL
$gpr = new-object "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1S_EmployeeDetails_WSDL.GetEmployeeRequestType"
$req.USERID = "U015412"
$req.clientID = "12345"
$person = $proxy.getEmployee($req)
$person.Person | select * | Format-List

#OUTPUT:
#Name : Smith
#FirstName : John

      

$person

- this GetEmployeeResponseType

, and I don't see methods like GetXML or anything like that. I found a similar thread here: How can I view the SOAP / XML that the webserver proxy class sends? but I'm not sure how I would intercept the call via PowerShell and if there is no better method. I also sometimes see people suggesting to use Fiddler ... I want the returned XML in PowerShell so that I can export it to a file. Export-Clixml

also doesn't do the trick since the PS object is exported and not the raw XML response .

+3


source to share





All Articles