如何使用dot42进行SOAP调用?

时间:2014-01-31 21:48:12

标签: dot42

我有以下代码。我知道webrequests等应该是异步调用,但我只是想要概念验证。

using System;
using Android.App;
using Android.Os;
using Android.Widget;
using Dot42;
using Dot42.Manifest;
using System.Xml;
using System.Net;
using System.IO;
using System.Text;

[assembly: Application("dot42Application6")]

namespace dot42Application6
{
    [Activity]
    public class MainActivity : Activity
    {
    protected override void OnCreate(Bundle savedInstance)
    {
        base.OnCreate(savedInstance);
        SetContentView(R.Layouts.MainLayout);
        string soap = @"<?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><GetColorChangeCharge xmlns=""http://reps.catalystinnovations.net/"">
        <password>ujnvusk</password></GetColorChangeCharge></soap:Body>    </soap:Envelope>";

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.someurl/service.asmx");
        req.Headers.Add("SOAPAction", "http://www.someurl/GetColorChangeCharge");
        req.ContentType = "text/xml; charset=utf-8";
        req.Accept = "text/xml";
        req.Method = "POST";

        using (Stream stm = req.GetRequestStream())
        {
            using (StreamWriter stmw = new StreamWriter(stm))
            {
                stmw.Write(soap);
            }
        }

        WebResponse resp = req.GetResponse();
        Stream responsStream = resp.GetResponseStream();

    }


}

}

我得到了一个java.lang.Runtime异常    WebResponse resp = req.GetResponse(); 我不知道问题是什么或如何修复它。

0 个答案:

没有答案