0

REST API を介して Azure でインスタンスをプロビジョニングするためのこのコードがあります。前回確認した時はエラーなく動いていたのですが、今朝再度開いてデバッグするといきなり例外が発生。rootElement がありません。しかし、xml に rootElement を入れようとしても、まだ機能しません。

<?xml version="1.0" encoding="utf-8"?>
<rootElement>
...
</rootElement>

xml が正しく割り当てられているかどうかを確認します。何も問題はないようです。しかし、私にこのエラーを与えます。この問題の原因は何ですか

string myURL = "https://management.core.windows.net/mySubscriptionID/services/hostedservices/CloudService/deployments";
    string postBodyFileName = @"C:\Users\CompName\Desktop\REST API\VM-CreateVM.xml";
    string subscriptionID = ConfigurationManager.AppSettings["Subscription"];
    string certificatePath = ConfigurationManager.AppSettings["CertificatePath"];
    protected void Button1_Click(object sender, EventArgs e)
    {
        Uri requestUri = new Uri(myURL);

        // Create the request and specify attributes of the request.
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);

        // Define the required headers to specify the API version and operation type.
        request.Headers.Add("x-ms-version", "2012-03-01");
        request.Method = "POST";
        request.ContentType = "application/xml";
        XmlDocument xDoc = new XmlDocument();
        xDoc.Load(postBodyFileName);

        Stream requestStream = request.GetRequestStream();
        StreamWriter streamWriter = new StreamWriter(requestStream, System.Text.UTF8Encoding.UTF8);
        xDoc.Save(streamWriter);
        streamWriter.Close();
        requestStream.Close();

        X509Certificate2 myCert = new X509Certificate2(certificatePath);
        request.ClientCertificates.Add(myCert);

        // Make the call using the web request.
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        HttpStatusCode responseStatus = response.StatusCode;
        Stream responseStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(responseStream);

        XmlDocument xDocResp = new XmlDocument();
        xDocResp.Load(reader);

        string operationsResponse = xDocResp.SelectSingleNode("/*[local-name()='Operation' and namespace-uri()='http://schemas.microsoft.com/windowsazure']/*[local-name()='Status' and namespace-uri()='http://schemas.microsoft.com/windowsazure']").InnerXml;

    }
4

0 に答える 0