none
WebService (SOAP) Call using PowerShell Fails with XML Error - But Fiddler Shows the response RRS feed

  • Question

  • Folks,

    I am calling a WebService (SOAP) which should respond with ticket information etc.. etc..

    However, when I call the webservice with the associated method, I get the following on PowerShell

    Exception calling "Service" with "3" argument(s): "There is an error in XML document (3, 4)."

    Now the owner of the WebService (not me), is able to use SOAP UI and show the response and it showed it ok.

    To further troubleshoot, I used Fiddler and ran the PowerShell Command. Now in Fiddler response, I could see the XML response with all the ticket details.

    I can see that W3Schools XML Validator shows a small error in the XML (I think a "-"_

    While Obvious answer would be to fix the webservice, however that is a long process ...

    Is there a ignore kind of option in PowerShell for not well-formatted XML responses?


    Regards, Vik Singh "If this thread answered your question, please click on "Mark as Answer"

    Friday, December 30, 2016 7:30 AM

Answers

  • You can download the WSDL as XML text and review what is causing the issue.


    \_(ツ)_/

    • Marked as answer by Vik Singh Friday, December 30, 2016 8:55 AM
    • Unmarked as answer by Vik Singh Friday, December 30, 2016 8:57 AM
    • Marked as answer by Vik Singh Friday, December 30, 2016 8:57 AM
    Friday, December 30, 2016 8:48 AM

All replies

  • There is no way that I know of to alter Invoke-WebRequest to ignore malformed XML responses.

    You should be using New-WebServiceProxy to send or implement web service access as this can resolve many issues by loading the WSDL and the associated schemas.


    \_(ツ)_/

    Friday, December 30, 2016 8:11 AM
  • Hi JRV,

    That is what I am using

    $proxy = New-WebServiceProxy -Uri $ars

    regards,
    Vikram


    Regards, Vik Singh "If this thread answered your question, please click on "Mark as Answer"

    Friday, December 30, 2016 8:33 AM
  • There is no way to ignore errors generated by the service.  Contact the service owner for assistance.  Some services require extra steps to return a correct service proxy.


    \_(ツ)_/

    Friday, December 30, 2016 8:39 AM
  • A question for my knowledge. Instead of using PowerShell Cmdlets..

    If we use a .Net Code within PowerShell by using System.x.

    Would we be able to handle the not so well-formatted response? Or would that also fail?


    Regards, Vik Singh "If this thread answered your question, please click on "Mark as Answer"

    Friday, December 30, 2016 8:41 AM
  • That is what New-WebServiceProxy does.  It is just a wrapper around Sys.Net.WebRequest

    https://msdn.microsoft.com/en-us/library/bb310979.aspx


    \_(ツ)_/

    Friday, December 30, 2016 8:46 AM
  • You can download the WSDL as XML text and review what is causing the issue.


    \_(ツ)_/

    • Marked as answer by Vik Singh Friday, December 30, 2016 8:55 AM
    • Unmarked as answer by Vik Singh Friday, December 30, 2016 8:57 AM
    • Marked as answer by Vik Singh Friday, December 30, 2016 8:57 AM
    Friday, December 30, 2016 8:48 AM
  • The wrapper piece is understood. Just thought that is some extra function or step in .Net which could make this work.

    XML surely has errors. The validator found it.

    Thanks


    Regards, Vik Singh "If this thread answered your question, please click on "Mark as Answer"

    Friday, December 30, 2016 8:57 AM
  • You can use this:

    $xml=Invoke-WebRequest 'http://www.webservicex.net/uszip.asmx?WSDL'|select -expand content

    And this:

    $uri= 'http://www.webservicex.net/uszip.asmx?WSDL'
    $zip = New-WebServiceProxy -Uri $uri


    \_(ツ)_/

    Friday, December 30, 2016 8:58 AM