Code Update in Windows Phone 8.1

0

I'm making a transition from silverlight to runtime, my application requires a connection to the webservice, and in that case the error is occurring, some things I managed to change, for example: WebClient by HttpClient.

    
asked by anonymous 24.06.2015 / 17:36

1 answer

0

I always use RestSharp for service calls in my apps. Very easy to use. Example:

var urlBase = "http://url_do_seu_webservice_sem_o_nome_do_servico"
var nomeServico = "ServicoUsuario.asmx?op=EfetuarLogin"; // Nome do servico e operação

var client = new RestClient(urlBase);

var request = new RestRequest(nomeServico, Method.POST);
request.RequestFormat = RestSharp.DataFormat.Xml;


string xml = @"<?xml version='1.0' encoding='utf-8'?>
  <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>
      ... Dados do seu XML ...
    </soap:Body>
  </soap:Envelope>";

request.AddParameter("text/xml", xml, ParameterType.RequestBody);

client.ExecuteAsync(request, (response) =>
{
    var resposta = response.Content;
});
    
29.06.2015 / 15:12