将查询发布到soap webservice asp.net

时间:2019-05-10 20:05:15

标签: asp.net web-services soap soap-client

我想将Web服务集成到我的项目中 没有服务文件...这里是 文档中的样本

连接到服务:

 $cl= new \SoapClient(null, array(
            'location' => 'http://tpg.ua/avia.php',
            'uri' => 'http://tpg.ua/avia.php',
            'login' => 'login','password' => 'password'
   ));
他们寄给我两张照片 enter image description here enter image description here

我该怎么办?我写了他们的支持书,但他们不在乎

我写了这段代码,但是返回空值

  string content = @"<? xml version = ""1.0"" encoding = ""utf-8"" ?>
                           <soap:Envelope 
                             xmlns:soap = ""http://schemas.xmlsoap.org/soap/envelope/"">
                           <soap:Header>
                  <getTicketPrices xmlns = ""http://tempuri.org/"">
              <login>tpg_webservice</login>
                <password>tpg12345</password>
            </getTicketPrices>
         </soap:Header>
         <soap:Body>
              <SENSITIVEDATA xmlns = ""http://tempuri.org/"" />
             </soap:Body>
            </soap:Envelope>";



        try
        {
            using (WebClient wClient = new WebClient())
            {
                wClient.Headers.Add("Content-Type", "text/xml; charset=utf-8");
                wClient.Headers.Add("SOAPAction", "http://tpg.ua/avia.php/getTicketPrices");
                var result = wClient.UploadData("http://tpg.ua/avia.php"
                    , "POST"
                    , Encoding.UTF8.GetBytes(content));
                var response = System.Text.Encoding.Default.GetString(result);
                Console.WriteLine(response);
            }
        }
        catch (WebException excp)
        {
            Console.WriteLine(excp.Message);
        }

0 个答案:

没有答案