01/10/2018, 08:46

Có ai xài Soap trên C# chưa anh em

có ai xài Soap trên C# chưa anh em nếu có rồi giúp mình với mình xài tool thì khi add WSDL ví dụ đường dẫn này http://demo.com/service?wsdl thì tự động nó sinh ra url post là http://demo.com/service/ws/1 mình truyền vào xml như sau REG
01695468585854
2000
test
45645645654645
thì nó chạy ok nhưng khi viết code thì nó lại báo lỗi 500 code của mình như sau
static void Main(string[] args)
{

        HttpWebRequest request = CreateWebRequest();
        XmlDocument soapEnvelopeXml = new XmlDocument();
        soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
            <soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:urn=""urn:FsubdayControllerwsdl"">
               <soapenv:Header/>
               <soapenv:Body>
                  <urn:actionFsubday soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">
                     <reason>REG</reason>
                     <msisdn>01695468585854</msisdn>
                     <totalamount>2000</totalamount>
                     <extinfo>test</extinfo>
                     <securecode>45645645654645</securecode>
                  </urn:actionFsubday>
               </soapenv:Body>
            </soapenv:Envelope>");
        using (Stream stream = request.GetRequestStream())
        {
            //soapEnvelopeXml.Save(stream);
        }

        using (WebResponse response = request.GetResponse())
        {
            using (StreamReader rd = new StreamReader(response.GetResponseStream()))
            {
                string soapResult = rd.ReadToEnd();
                Console.WriteLine(soapResult);
                Console.ReadLine();
            }
        }
    }
    public static HttpWebRequest CreateWebRequest()
    {
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"http//demo.com/servide/wsdl");
        
        webRequest.Headers.Add("SOAPAction", "Fsubday");
        webRequest.ContentType = "application/xml; charset=utf-8";
        webRequest.Accept = "text/xml";
        webRequest.Method = "POST";



        return webRequest;
    }

ai biết lỗi gì không giúp mình với

Bài liên quan
0