xml - Solving namespace issue when consuming remote webservice in .net 4.5 -


i'm trying consume web service provided our membership database service (imis).

here's example using wsdl on website.

httpclient client = new httpclient(); client.baseaddress = new uri("http://www.atsol.org/webservices_demo/wscontacts.asmx/"); var c = new formurlencodedcontent(new[]  {     new keyvaluepair<string, string>("username", "myname"),     new keyvaluepair<string, string>("password", "mypassword"),     new keyvaluepair<string, string>("updateloggedindate", "false") }); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/xml")); loginresultswithdata r = response.result.content.readasasync<loginresultswithdata>().result; 

it works fine when gets last line , attempts deserialize xml "loginresultswithdata" object runs error on name space.

error in line 1 position 163. expecting element 'loginresultswithdata' namespace 'http://schemas.datacontract.org/2004/07/myprojectname.imiscontactservice'.. encountered 'element' name 'loginresultswithdata', namespace 'http://www.atsol.org/wscontacts/'.

this response webservice

http/1.1 200 ok date: wed, 17 jul 2013 19:48:59 gmt server: microsoft-iis/6.0 x-powered-by: asp.net x-aspnet-version: 4.0.30319 cache-control: private, max-age=0 content-type: text/xml; charset=utf-8 content-length: 1202  <?xml version="1.0" encoding="utf-8"?> <loginresultswithdata xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns="http://www.atsol.org/wscontacts/">   <resultcode>#</resultcode>   <resultmessage>succeeded</resultmessage>   <id>####</id>   <institutecontactid>####</institutecontactid>   <ismember>false</ismember>   <isinstitute>false</isinstitute>   <customertypecode>s</customertypecode>   <billingcategory />   <contactstatuscode>a</contactstatuscode>   <paidthrudate>2099-12-31t00:00:00</paidthrudate>   <fullname>my name</fullname>   <firstname>my</firstname>   <lastname>name</lastname>   <informal>my</informal>   <roles />   <imiscookies>     <imiscookie>       <cookiename>asp.net_sessionid</cookiename>       <cookievalue>io0um25qmae35wiogsjgwrsq</cookievalue>     </imiscookie>     <imiscookie>       <cookiename>login</cookiename>       <cookievalue>34e1a645eb3f4ae693edee665d2328264c7f064b366de16286df83e6d79af7663294e1275da22703506f3e8e3f89d02c27dab30f2d6a4a43a3af1a6d0dcd1a2afdfd18073e6187111430228892a9c7ec</cookievalue>     </imiscookie>   </imiscookies> </loginresultswithdata> 

and before ask, no can't mess web-service. help?!

perhaps service provider has updated wsdl , client machinery needs regen response posted appears consistent types specified in wsdl @ http://www.atsol.org/webservices_demo/wscontacts.asmx?wsdl

based on error message, somewhere in web service client machinery incorrect namespace 'http://schemas.datacontract.org/2004/07/myprojectname.imiscontactservice' has been associated response element 'loginresultswithdata'.

the wsdl , posted response indicate loginresultswithdata associated namespace 'http://www.atsol.org/wscontacts/' (in wsdl:types section, covered targetnamespace="http://www.atsol.org/wscontacts/" attribute of schema element; in response, indicated attribute xmlns="http://www.atsol.org/wscontacts/" of loginresultswithdata element).


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -