编辑 我误解了这里发生的事情。.有一篇文章,然后收回结果,然后我在这里看到的URL字符串是查询字符串的一部分...所以我无法解码这是什么确实是,因为它是由付款网关人员而不是我编码的。

我想解码一个URL字符串

这是代码:

private string SubmitXml(string InputXml)
    {
        string result = InputXml.ToString();

        HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(_WebServiceUrl);
        webReq.Method = "POST";

        byte[] reqBytes;

        reqBytes = System.Text.Encoding.UTF8.GetBytes(InputXml);
        webReq.ContentType = "application/x-www-form-urlencoded";
        webReq.ContentLength = reqBytes.Length;
        webReq.Timeout = 5000;
        Stream requestStream = webReq.GetRequestStream();
        requestStream.Write(reqBytes, 0, reqBytes.Length);
        requestStream.Close();

        HttpWebResponse webResponse = (HttpWebResponse)webReq.GetResponse();

这是inputxml:

 - <GenerateRequest>
  <PxPayUserId>KoruCareCHCH_Dev</PxPayUserId> 
  <PxPayKey>47d99ccdcae54816ecd78c9a80f8878c466a7ed829480e59d421cc4c456cbd93</PxPayKey> 
  <AmountInput>345.00</AmountInput> 
  <BillingId /> 
  <CurrencyInput>NZD</CurrencyInput> 
  <DpsBillingId /> 
  <DpsTxnRef /> 
  <EmailAddress /> 
  <EnableAddBillCard /> 
  <MerchantReference>43</MerchantReference> 
  <TxnData1 /> 
  <TxnData2 /> 
  <TxnData3 /> 
  <TxnType>Purchase</TxnType> 
  <TxnId>43</TxnId> 
  <UrlFail>http://localhost:1527/Auction/PurchaseTickets.aspx</UrlFail> 
  <UrlSuccess>http://localhost:1527/Auction/PurchaseTickets.aspx</UrlSuccess> 
  <Opt /> 
  </GenerateRequest>

这是URL

https://sec2.paymentexpress.com/pxpay/pxpay.aspx?userid=KoruCareCHCH_Dev&request=v5lK0D7j3qnGqQVnj3WThhuS5PoWwKhdLUXfnL1hiSzYzxzkKVtTbLKC49e0qerYoTAofoBXfkWHjJdtOEV1MrnEBZ3p9b-G5fTsS-sLqc76RhHOb8HTxtwe0EQ1kz1iCf2ExIgKRod-FPQTKf6XoTLLlQ4jhcrO7yQczrq1Hft5pB98LMJCdBX0FDnA5NV0ZGApR0NaCMy-xbpsVSsyTbSdmp03aiHpGXI4up2RxrBFhbiEOZKtpKkjUpqJ90UuoXmFwqTC5Pj0g1mx3VRV2ee358Tnu1_kuEID_RaP8sZNTVlAMY5-8qjB-u0dgM4ya8Faxxyw5AhyE=

问题: 如何将URL请求解码= blahblah返回XML

我正在这样做来尝试证明URL字符串中包含的内容(应该像上面的XML一样!)

有帮助吗?

解决方案

解码它没有任何运气,因此URL可能是错误的,但是我使用了此代码:

Uri uri = new Uri(...);
NameValueCollection query = HttpUtility.ParseQueryString(uri.Query);
string value = query["request"].Replace('-', '+').Replace('_', '/');
Debug.WriteLine(Convert.FromBase64String(value));

编辑:在他们的文档中,他们说它已加密。

其他提示

您可以使用正则表达式

var match = new Regex("request=(?<key>[^&]+)").Match(url);

并在命名组中捕获请求值。从那里开始,希望您能够解释被捕获的价值。

不能保证上述正则是正确的 - 我尚未对其进行测试。它至少应该指向正确的方向!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top