c# - Switching from an asmx to a svc web service -


we upgraded web services asmx wcf, need change call web service in application, contract name , method names , signatures same. there easy way go calling asmx web service svc web service (wcf)?

     internal xmldocument servicecall()      {         webresponse reponseweb = null;         string strreponse = string.empty;          httpwebrequest webrequest = this.createwebquery();          xmldocument soapenvelopexml = this.creerenveloppesoap();          using (stream stream = webrequest.getrequeststream())         {             soapenvelopexml.save(stream);         }          xmldocument xmlsoaprequest = new xmldocument();          try         {             reponseweb = webrequest.getresponse();         }         catch (system.exception ex)         {             throw ex;         }          stream str = reponseweb.getresponsestream();         streamreader sr = new streamreader(str);          xmlsoaprequest.load(sr);         return xmlsoaprequest;      }      private httpwebrequest createwebquery()     {         httpwebrequest webrequest = (httpwebrequest)webrequest.create(this.urlserviceweb);         webrequest.headers.add("soapaction", "\"" + this.urlhost + this.wcfnamecontrat + "/" + this.methodeweb + "\"");         webrequest.contenttype = "application/soap+xml; charset=utf-8";         webrequest.accept = "text/xml";         webrequest.method = "post";         return webrequest;     }      private xmldocument creerenveloppesoap()     {         xmldocument soapenvelop = new xmldocument();          string appelmethode = "<" + this.methodeweb + " xmlns=" + "\"" + this.urlhote + this.wcfnomcontrat + "\"" + ">";          string strparametres = string.empty;         foreach (parametre param in this.parametres)         {             strparametres = strparametres + "<" + param.nom + ">" + param.valeur + "</" + param.nom + ">";         }          appelmethode = appelmethode + strparametres + "</" + this.methodeweb + ">";          stringbuilder sb = new stringbuilder(_enveloppesoap);         sb.insert(sb.tostring().indexof("</soap12:body>"), appelmethode);          // xml         soapenvelop.loadxml(sb.tostring());         return soapenvelop;     } 

i tried change web service address in .config file , gave me error :

(415) cannot process message because content type 'application/soap+xml; charset=utf-8' not expected type 'text/xml; charset=utf-8'.. 

so in createwebquery method changed :

 webrequest.contenttype = "application/soap+xml; charset=utf-8"  

to

 webrequest.contenttype "text/xml;charset=utf-8" 

the web service call returned :

the remote server returned error: (400) bad request. 

i'm not familiar wcf services, appreciated.

thanks.

what binding have used? make sure basichttpbinding - may not have change in client


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -