Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何发送2个xml请求soap?_C#_.net_Xml_Soap - Fatal编程技术网

C# 如何发送2个xml请求soap?

C# 如何发送2个xml请求soap?,c#,.net,xml,soap,C#,.net,Xml,Soap,我有一个包含两个XML字符串的列表,下面是C代码: 字符串sb=”“; List LISTGAME=新列表(); sb=(“在代码中应用循环以逐个发送请求。如果wsdl不允许,则不能同时发送两个请求 在wsdl中检查您的请求消息格式,它是否将请求作为您在代码中定义的字符串列表 对于列表中的每个字符串,重复以下代码 HttpWebRequest req = (HttpWebRequest)WebRequest.Create("urlofmy.asmx"); 请求标题添加(“SOAPAction”

我有一个包含两个XML字符串的列表,下面是C代码:

字符串sb=”“;
List LISTGAME=新列表();

sb=(“在代码中应用循环以逐个发送请求。如果wsdl不允许,则不能同时发送两个请求

在wsdl中检查您的请求消息格式,它是否将请求作为您在代码中定义的字符串列表

对于列表中的每个字符串,重复以下代码

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("urlofmy.asmx");
请求标题添加(“SOAPAction”、“URLSOAAPAction”); req.ContentType=“text/xml;字符集=\”utf-8\”; req.Accept=“text/xml”; 请求方法=“POST”

对于每个xml请求,您还将得到多个响应

还有一件事,您可以从wsdl粘贴您的请求消息结构。可能是您可以在单个请求消息中发送多个rquest(取决于您的wsdl请求消息结构)

编辑代码:

string sb = "";
List<string> listGamme = new List<string>();
sb = ("<?xml....") ;//1st listGamme
listGamme.Add(sb);
sb = ("<?xml..."); //2nd listGamme
listGamme.Add(sb);

foreach (string gamme in listGamme)
                        {
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("urlofmy.asmx");
    req.Headers.Add("SOAPAction", "URLSOAPACTION");
    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(gamme); 

                 }

            }

    WebResponse response = req.GetResponse();
    StreamReader srreader = new StreamReader(response.GetResponseStream());
}
字符串sb=”“;
List LISTGAME=新列表();

sb=(“如何应用循环来逐个发送请求?我得到了这个消息系统。ArgumentException:流不可写请将您的wsdl粘贴到这里。我只需要它的请求消息结构。有什么原因不能简单地使用“添加服务引用”?请参阅
            using (Stream stm = req.GetRequestStream())
            {

                using (StreamWriter stmw = new StreamWriter(stm))
                {
                     foreach (string gamme in listGamme)
                        {

                             stmw.Write(gamme);

                         }   

                 }

            }

WebResponse response = req.GetResponse();
    StreamReader srreader = new StreamReader(response.GetResponseStream());
string sb = "";
List<string> listGamme = new List<string>();
sb = ("<?xml....") ;//1st listGamme
listGamme.Add(sb);
sb = ("<?xml..."); //2nd listGamme
listGamme.Add(sb);

foreach (string gamme in listGamme)
                        {
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("urlofmy.asmx");
    req.Headers.Add("SOAPAction", "URLSOAPACTION");
    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(gamme); 

                 }

            }

    WebResponse response = req.GetResponse();
    StreamReader srreader = new StreamReader(response.GetResponseStream());
}