c# - Using LINQ to XML to Parse a SOAP message -
i getting speed in linq xml in c# , attempting parse following message , don't seem making progress. here soap message not sure if perhaps need use namespace. here soap message trying format. appreciated. attempting extract values. thanks.
<soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <lookup xmlns="http://asr-rt/"> <objin> <transactionheaderdata> <intwebsiteid>1000</intwebsiteid> <strvendordata>test</strvendordata> <strvendorid>i07</strvendorid> </transactionheaderdata> <intccn>17090769</intccn> <strsurveyresponseflag>y</strsurveyresponseflag> </objin> </ccnlookup> </soap:body> </soap:envelope>
if interacting soap service please use add service reference or wsdl.exe.
if parsing xml, assuming you've got soap response xdocument named soapdocument:
xnamespace ns = "http://asr-rt/"; var objins = objin in soapdocument.descendants(ns + "objin") let header = objin.element(ns + "transactionheaderdata") select new { websiteid = (int) header.element(ns + "intwebsiteid"), vendordata = header.element(ns + "strvendordata").value, vendorid = header.element(ns + "strvendorid").value, ccn = (int) objin.element(ns + "intccn"), surveyresponse = objin.element(ns + "strsurveyresponseflag").value, };
that give ienumerable of anonymous types deal typed objects within method.
Comments
Post a Comment