nell'app del mio Windows phone Devo usare la classe XmlDocument. Ma ho ancora erroriWindows Phone - Impossibile trovare XmlDocument
Error 1 The type or namespace name 'XmlDocument' could not be found (are you missing a using directive or an assembly reference?)
ho aggiunto riferimento e using System.Xml
Ma non aiuta.
Questo è il mio codice di esempio SOAP, che ho bisogno di modificare a lavorare con XDocument Modifica - Aggiunta SOAP codice di esempio
public static void CallWebService()
{
var _url = "http://xxxxxxxxx/Service1.asmx";
var _action = "http://xxxxxxxx/Service1.asmx?op=HelloWorld";
XmlDocument soapEnvelopeXml = CreateSoapEnvelope()
HttpWebRequest webRequest = CreateWebRequest(_url, _action);
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
// do something usefull here like update your UI.
asyncResult.AsyncWaitHandle.WaitOne();
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
Console.Write(soapResult);
}
private static HttpWebRequest CreateWebRequest(string url, string action)
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Headers.Add("SOAPAction", action);
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
}
private static XmlDocument CreateSoapEnvelope()
{
XmlDocument soapEnvelop = new XmlDocument();
soapEnvelop.LoadXml(@"<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/1999/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/1999/XMLSchema""><SOAP-ENV:Body><HelloWorld xmlns=""http://tempuri.org/"" SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""><int1 xsi:type=""xsd:integer"">12</int1><int2 xsi:type=""xsd:integer"">32</int2></HelloWorld></SOAP-ENV:Body></SOAP-ENV:Envelope>");
return soapEnvelop;
}
private static void InsertSoapEnvelopeIntoWebRequest(XmlDocument soapEnvelopeXml, HttpWebRequest webRequest)
{
using (Stream stream = webRequest.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
}`
perché non si sta utilizzando Linq su Xml/XDocument? – BrokenGlass
Probabilmente vale la pena controllare: [Come usare webservice nell'applicazione Windows Phone 7] (http://www.codeproject.com/Questions/355937); [Windows Phone 7 in 7: connessione ai servizi Web] (http://msdn.microsoft.com/en-us/gg241261.aspx); [Consumo del servizio Web ASMX da Windows Phone 7] (http://social.msdn.microsoft.com/Forums/wpapps/en-US/38815099-8394-448c-80bf-a93279fbbdac/); [Creazione riferimento servizio: impossibile generare codice per il riferimento del servizio] (http://software-development-toolbox.blogspot.ru/2009/02/creating-service-reference-failed-to.html) – GSerg