C# 找不到Windows Phone-XmlDocument

C# 找不到Windows Phone-XmlDocument,c#,windows-phone-7,xmldocument,C#,Windows Phone 7,Xmldocument,在我的windows phone应用程序中,我需要使用XmlDocument类。但我还是会出错 错误1找不到类型或命名空间名称“XmlDocument”(是否缺少using指令或程序集引用? 我添加了参考和 使用System.Xml 但这没用 这是我的SOAP示例代码,我需要修改它以使用XDocument 编辑-添加SOAP示例代码 public static void CallWebService() { var _url = "http://xxxxxxxxx/Ser

在我的windows phone应用程序中,我需要使用XmlDocument类。但我还是会出错

错误1找不到类型或命名空间名称“XmlDocument”(是否缺少using指令或程序集引用?

我添加了参考和
使用System.Xml

但这没用

这是我的SOAP示例代码,我需要修改它以使用XDocument 编辑-添加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);
        }
    }`
publicstaticvoid CallWebService()
{
var_url=”http://xxxxxxxxx/Service1.asmx";
var_action=”http://xxxxxxxx/Service1.asmx?op=HelloWorld";
XmlDocument soapEnvelopeXml=CreateSoapEnvelope()
HttpWebRequest webRequest=CreateWebRequest(_url,_action);
插入SOAPEnvelopeInToWebRequest(SOAPEnvelopeExML,webRequest);
//开始对web请求的异步调用。
IAsyncResult asyncResult=webRequest.BeginGetResponse(null,null);
//挂起此线程,直到调用完成。您可能希望
//在这里做一些有用的事情,比如更新你的UI。
asyncResult.AsyncWaitHandle.WaitOne();
//从已完成的web请求中获取响应。
字符串soapResult;
使用(WebResponse WebResponse=webRequest.EndGetResponse(asyncResult))
使用(StreamReader rd=newstreamreader(webResponse.GetResponseStream()))
{
soapResult=rd.ReadToEnd();
}
Console.Write(soapResult);
}
私有静态HttpWebRequest CreateWebRequest(字符串url,字符串操作)
{
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”;
返回webRequest;
}
私有静态XmlDocument CreateSOApevelope()
{
XmlDocument SOAPEnvelope=新的XmlDocument();
LoadXml(@“1232”);
返回信封;
}
私有静态void InsertSoapEnvelopeIntoWebRequest(XmlDocument SoapEnvelopeExML,HttpWebRequest webRequest)
{
使用(Stream-Stream=webRequest.GetRequestStream())
{
soapEnvelopeXml.Save(流);
}
}`
Its

Linq的示例如下:

源代码示例:

为什么不改用Linq to Xml/XDocument?可能值得一查:;好的,我知道这里不存在XmlDocument,所以我必须使用XDocument。现在我的问题是,我正在开发基于SOAP的应用程序,我必须解析通过SOAP发送的XML。我这里有一些例子,但我不知道如何修改它。我很高兴,你找到了一个解决方案。为您添加了一个问题;我读不出这个问题。你能重新表述一下问题是什么吗?我的问题是我有一个C#SOAP客户端示例,我需要修改它以使用XDocument。我在任何地方都找不到如何在WP7上执行SOAP请求的工作示例。