PowerShell HTTP 500 response error body
in powershell, i'm calling soap web service , getting http 500 error @ line
[system.net.webresponse]$resp=$webrequest.getresponse()
and $_ error object returns:
the remote server returned error: (500) internal server error.
how full error details that contained in soap fault string? (i see in fiddler).
the errordetails property blank , don't see how soap fault string.
typename: system.management.automation.errorrecord
name membertype definition
---- ---------- ----------
equals method bool equals(system.object obj)
gethashcode method int gethashcode()
getobjectdata method void getobjectdata(system.runtime.serialization.serializationinfo info, system.runtime.serialization.strea...
gettype method type gettype()
tostring method string tostring()
categoryinfo property system.management.automation.errorcategoryinfo categoryinfo {get;}
errordetails property system.management.automation.errordetails errordetails {get;set;}
exception property system.exception exception {get;}
fullyqualifiederrorid property string fullyqualifiederrorid {get;}
invocationinfo property system.management.automation.invocationinfo invocationinfo {get;}
pipelineiterationinfo property system.collections.objectmodel.readonlycollection[int] pipelineiterationinfo {get;}
scriptstacktrace property string scriptstacktrace {get;}
targetobject property system.object targetobject {get;}
psmessagedetails scriptproperty system.object psmessagedetails {get=& { set-strictmode -version 1; $this.exception.innerexception.psmessag...
i already tried below code in catch block but $ex.reponse returns nothing.
catch[system.net.webexception] {
$ex=$_
if ($ex-ne$null) {
$resp=$ex.response;
$rs=$resp.getresponsestream();
[system.io.streamreader]$sr=new-objectsystem.io.streamreader-argumentlist$rs;
[string]$results=$sr.readtoend();
return$results;
}
else{
return$ex
}
}
Windows Server > Windows PowerShell
Comments
Post a Comment