私のWindowsの電話アプリXmlDocumentクラスを使用する必要があります。しかし、私はまだ私が参照して using System.Xml
Windows Phone - XmlDocumentが見つかりません
を追加しましたエラー
Error 1 The type or namespace name 'XmlDocument' could not be found (are you missing a using directive or an assembly reference?)
を取得しかし、それは助けをdoesntの。
これは私がXDocument 編集で動作するように変更する必要があることを、私のSOAPのコード例である - を追加しましたSOAPのサンプルコード
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);
}
}`
なぜLinq to Xml/XDocumentを使用していませんか? – BrokenGlass
おそらくチェック価値があります:[Windows Phone 7アプリケーションでWebサービスを使用する方法](http://www.codeproject.com/Questions/355937); [Windows Phone 7 7:Webサービスへの接続](http://msdn.microsoft.com/en-us/gg241261.aspx) [Windows Phone 7からASMX Webサービスを使用する](http://social.msdn.microsoft.com/Forums/wpapps/en-US/38815099-8394-448c-80bf-a93279fbbdac/); [サービス参照の作成:サービス参照のコードの生成に失敗しました](http://software-development-toolbox.blogspot.ru/2009/02/creating-service-reference-failed-to.html) – GSerg