读取XMLStreamReader时出错。获取故障响应

时间:2018-08-04 12:39:39

标签: c# asp.net soap

我已经开发了一个应用程序,用户应在该应用程序中填写该应用程序,并应在最后付款。

要进行付款,用户应在下面提供的链接中填写详细信息。

Payment

应在我开发的应用程序中输入相同的详细信息。

当我尝试使用上述详细信息运行代码时,出现异常“读取XMLStreamReader出错”。

代码在下面给出

public void execute()
    {
        System.Net.ServicePointManager.Expect100Continue = false;
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

        try
        {
            string uri = "https://xxx/Service?wsdl";
            string soap = @"<?xml version=""1.0"" encoding=""utf-8""?>
           <SOAP-ENV:Envelope xmlns:SOAP- 
           ENV=""http://www.w3.org/2001/12/soap-envelope""SOAP- 
           ENV:encodingStyle=""http://www.w3.org/2001/12/soap-encoding"">
           <SOAP-ENV:Header xmlns=""http://service.receivevalidatechallan.dept.rct.integration.ifms.gov.in/"">
          <agencyCode 
      xmlns=""http://header.ei.integration.ifms.gov.in/"">EA_DCD</agencyCode>
          <integrationCode 
 xmlns=""http://header.ei.integration.ifms.gov.in/"">RCT033</integrationCode>
         <uirNo xmlns=""http://header.ei.integration.ifms.gov.in/"">EA_DCD- 
         RCT033-31082017-001</uirNo>
         </SOAP-ENV:Header>
         <SOAP-ENV:Body>
         <envelopedDataReq><Signature>-----BEGIN PKCS7----- 
 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIAwggNeMIIC
 RqADAgECAgRUDUiYMA0GCSqGSIb3DQEBCwUAMHExCzAJBgNVBAYTAklOMRIwEAYDVQQIEwlraGFq
 YW5lZWExEjAQBgNVBAcTCWtoYWphbmVlYTESMBAGA1UEChMJa2hhamFtZWVhMRIwEAYDVQQLEwlr
 a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xMQswCQYDVQQGEwJJTjESMBAGA1UECBMJa2hhamFuZWVhMRIw
 EAYDVQQHEwlraGFqYW5lZWExEjAQBgNVBAoTCWtoYWphbWVlYTESMBAGA1UECxMJa2hhamFuZWVh
 MRIwEAYDVQQDEwlraGFqYW5lZWECBFQNSJgwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkq
 hkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE3MDkwNzA3MjQ1NFowIwYJKoZIhvcNAQkEMRYEFJzo
 8N5KkBJXKAT8yvxMfhsdDFinMA0GCSqGSIb3DQEBAQUABIIBADz43QoVuAqLwhUxlVvsM3cV9S0T
 k220X / f55YBYzQYvmdq6lPIRkvrU9OOKQ4Ot4v05VpkbFOlgWuC + ShhqLPCZk + roU + 
 nWYxgqr2kS
 evWIh6zLi + 00X2L2skslzpufbk6kTNtkfJAs8y1AEi4T6Z13ibseT + TMaXWiO58AX / 
 xESJCf3NFI
 q54Tlmh3tg1RBbStRkixU06ZW1Cy8ubTpCVyiJK3BV9uuOD96QNbHEYq8qcMqd07PWxOpRfSsdNH
 mbxwvoajwsE16fswQ8ukZ7EP2R0o5mOAFR2AbmrA809Z5Z + 
  T4v9sjF7QE5lPQriTlBN0k1G3qCNW
   CRXZRKN3qCQAAAAAAAA=-----END PKCS7-----</Signature>
  <data>
 <RctReceiveValidateChlnRq>
 <chlnDate>01/09/2018</chlnDate>
 <deptCode>15E</deptCode>
 <ddoCode>19929D</ddoCode>
 <deptRefNum>DCD1700250</deptRefNum>
 <rctReceiveValidateChlnDtls>
 <rmtrName>Ram</rmtrName>
 <totalAmount>10</totalAmount>
 <trsryCode>572H</trsryCode>
 <amount>1</amount>
 <deptPrpsId>DMD397FB5D7DC06E</deptPrpsId>
 <prpsName>0701~80~800~0~02~000</prpsName>
 <subPrpsName>12</subPrpsName>
 </rctReceiveValidateChlnDtls>
 </RctReceiveValidateChlnRq>
 </data>
 </envelopedDataReq>
 </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            request.Headers.Add("SOAP:Action");
            request.ContentType = "text/xml;charset=\"utf-8\"";
            request.Accept = "text/xml";
            request.Method = "POST";

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

            using (WebResponse webResponse = request.GetResponse())
            {
                using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
                {
                    string soapResult = rd.ReadToEnd();
                    //Console.WriteLine(soapResult);
                    string s = soapResult;
                }
            }
        }
        catch (WebException e)
        {
            string message = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
        }
    }

0 个答案:

没有答案