Code update on Windows Phone 8.1

Asked

Viewed 25 times

0

I am transitioning from Silverlight to Runtime, my application requires a connection to the webservice and precisely in it is occurring the error, some things I managed to change as for example: Webclient by Httpclient.

erro na aquisição

1 answer

0

I always use the 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;
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.