To retrieve an XML response from PowerShell's New-WebServiceProxy cmdlet, you can make use of the InvokeMethod method provided by the generated web service proxy class. Here's an example:

powershell
# Create a web service proxy $proxy = New-WebServiceProxy -Uri "http://example.com/your-web-service?wsdl" # Call a web service method $response = $proxy.YourWebServiceMethod() # Convert the response to XML $xmlResponse = [xml]$response

In the above example, replace "http://example.com/your-web-service?wsdl" with the actual URL of your web service's WSDL file. The New-WebServiceProxy cmdlet will generate a proxy class based on the WSDL, allowing you to call web service methods.

Once you have called a web service method using the proxy, you can assign the response to a variable ($response in this case). Then, you can use the [xml] type accelerator to explicitly cast the response to an XML object ([xml]$response), which provides XML parsing and manipulation capabilities.

With the $xmlResponse variable, you can access and manipulate the XML data as needed in your PowerShell script.

Note that the structure and available methods of the generated web service proxy class depend on the specific WSDL and web service you are working with. Be sure to consult the documentation or explore the generated class to understand the available methods and their expected responses.

Have questions or queries?
Get in Touch