2016-08-30 4 views
-2
나는 GitHub의 닷넷 라이브러리를 사용하여 MPI 서버에 3D 보안 등록 요청을 보낼 Realex의 XML API를하고 있어요

는 여기에서 찾을 : https://github.com/JonCanning/RealEx.NET역 직렬화가 예상대로 작동하지

처음 두 단계를 의 인증 프로세스가 3D 보안 테스트 카드 4012001037141112에서 잘 작동합니다. 성공적인 3D 보안 자동 서명이 필요하지만 .Net 클래스 아래에서 XML의 비 직렬화를 시도하면 ThreeDSecure는 절대 채워지지 않으며 그에 따라 XML이 채워지더라도 항상 null입니다. :

<response timestamp="20160830142152"> 
    <merchantid>*****</merchantid> 
    <account>internet</account> 
    <orderid>92f669c7-6fb3-43e0-bfb9-8f62aca128cf</orderid> 
    <authcode /> 
    <result>00</result> 
    <message>Authentication Successful</message> 
    <pasref /> 
    <timetaken>0</timetaken> 
    <authtimetaken>0</authtimetaken> 
    <threedsecure> 
    <status>Y</status> 
    <eci>5</eci> 
    <cavv>AAACBDlZYkmAggkgJVliAAAAAAA=</cavv> 
    <xid>ZFD6gQMih8V5gzA3q/XODcrx8N8=</xid> 
    <algorithm>2</algorithm> 
    </threedsecure> 
    <sha1hash>a9800768d3e683de4cf074195884d67d29f79189</sha1hash> 
</response> 
namespace RealEx 
{ 
    [XmlRoot("response")] 
    public class RealExResponse 
    { 
     [XmlElement("result")] 
     public string Result { get; set; } 
     [XmlElement("message")] 
     public string Message { get; set; } 
     [XmlElement("pasref")] 
     public string PasRef { get; set; } 
     [XmlElement("authcode")] 
     public string AuthCode { get; set; } 
     [XmlElement("pareq")] 
     public string PaReq { get; set; } 
     [XmlElement("enrolled")] 
     public string Enrolled { get; set; } 
     [XmlElement("xid")] 
     public string Xid { get; set; } 
     [XmlElement("orderid")] 
     public string OrderId { get; set; } 
     [XmlElement("sha1hash")] 
     public string Sha1Hash { get; set; } 
     [XmlElement("merchantid")] 
     public string MerchantId { get; set; } 
     [XmlElement("account")] 
     public string Account { get; set; } 
     [XmlElement("timetaken")] 
     public string TimeTaken { get; set; } 
     [XmlElement("authtimetaken")] 
     public string AuthTimeTaken { get; set; } 
     [XmlElement("url")] 
     public string Url { get; set; } 
     [XmlAttribute("timestamp")] 
     public string TimeStamp { get; set; } 
     [XmlElement("threedsecure")] 
     public ThreeDSecure ThreeDSecure { get; set; } 
     [XmlElement("cvnresult")] 
     public string CvnResult { get; set; } 
     [XmlElement("avspostcoderesponse")] 
     public string AvsPostcodeResponse { get; set; } 
     [XmlElement("avsaddressresponse")] 
     public string AvsAddressResponse { get; set; } 
     [XmlElement("batchid")] 
     public string BatchId { get; set; } 
     [XmlElement("cardissuer")] 
     public CardIssuer CardIssuer { get; set; } 

     internal static RealExResponse Deserialize(string xml) 
     { 
      return new XmlSerializer(typeof(RealExResponse)).Deserialize(XDocument.Parse(xml).CreateReader()) as RealExResponse; 
     } 
    } 
} 


namespace RealEx 
{ 
    public class ThreeDSecure 
    { 
     public string Status { get; set; } 
     public string Eci { get; set; } 
     public string Cavv { get; set; } 
     public string Xid { get; set; } 
     public string Algorithm { get; set; } 
    } 
} 

namespace RealEx 
{ 
    public class RealEx3DAuthRequest : RealExAuthRequest 
    { 
     public RealEx3DAuthRequest(string secret, string merchantId, string account, string orderId, Amount amount, Card card, TssInfo tssInfo, ThreeDSecure threeDSecure, bool autoSettle, string custNum, string prodId, string varRef, Comments comments) 
      : base(secret, merchantId, account, orderId, amount, card, tssInfo, autoSettle, custNum, prodId, varRef, comments) 
     { 
      Mpi = new Mpi(threeDSecure.Cavv, threeDSecure.Xid, threeDSecure.Eci); 
     } 
     public Mpi Mpi { get; private set; } 
    } 
} 

내가 제대로 작성되고있는 다른 속성의 모든 사람이 나를 도울 수있을 때 응답으로 수신 된 정보는 클래스에 기록되지 않는 이유를 이해하지 못할 다음과 같이 닷넷 클래스코드는 이 문제를 이해하고 있습니까?

+1

@EdPlunkett @EdPlunkett 올바른 형식으로 편집 할 수 있도록 이스케이프 문자가 포함 된 문자열입니다. –

+1

@EdPlunkett XML로 구문 분석하지 못했다고 주장하는 것은 조금 솔직하지 못했습니다. –

+0

@CharlesMager 문자열에서 백 슬래시가 실제 백 슬래시로 판명 된 곳에서 질문을 보았습니다. 당신은 정말로이 사람들과 모릅니다. 나는 당신이 그것에 대해 생각할 때 그가 이해할 수있는 것보다 더 많은 노력을 기울였습니다. –

답변

2

ThreeDSecure 속성이 XML의 이름과 일치하지 않습니다. 어느 일치하는 이름을 변경 (즉, 케이스 변경) 또는 적합한 속성을 추가 : AS를

public class ThreeDSecure 
{ 
    [XmlElement("status")] 
    public string Status { get; set; } 
    [XmlElement("eci")] 
    public string Eci { get; set; } 
    [XmlElement("cavv")] 
    public string Cavv { get; set; } 
    [XmlElement("xid")] 
    public string Xid { get; set; } 
    [XmlElement("algorithm")] 
    public string Algorithm { get; set; } 
} 

를 제외하고, 역 직렬화하기 전에 DOM으로 XML을 구문 분석 할 필요가 없습니다. 대신 StringReader을 사용하십시오.

using (var reader = new StringReader(xml)) 
{ 
    return (RealExResponse)new XmlSerializer(typeof(RealExResponse)).Deserialize(reader); 
}   
+0

감사합니다 찰스 바보 감독 지금 내가 보니 :) 덕분에 많은 도움을 주셔서 감사합니다. – Jay

관련 문제