2017-05-12 4 views
0

먼저 내가이 오래된 기술을 알고 있다고 말하고 싶습니다. 내게 달려 있다면 인생은 달라질 것입니다. 나는이 오래된 기술에 비교적 익숙하지 않다. 나는 직장에서 기존 서비스를 확장하고 있으며 이상한 문제를 겪고있다. 3 개의 서비스 엔드 포인트가 있고 그 중 2 개가 예상대로 작동하지만 세 번째 문제점은 "프레임 워크"가 xml 요청을 비 직렬화하는 데 실패한 것입니다.ASMX 서비스 XML 요청 부분적으로 역 직렬화

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soap:Body> 
     <UpdateSale xmlns="http://tokenws.netgen.co.za/"> 
     <p_objrequest> 
      <transactionTypeId>1</transactionTypeId> 
      <tenderTypeId>1</tenderTypeId> 
      <standardHeader> 
       <requestId xmlns="">1_8</requestId> 
       <localeId xmlns="" /> 
       <systemId xmlns="">asdf</systemId> 
       <batchReference xmlns="">11</batchReference> 
      </standardHeader> 
      <account> 
       <accountId xmlns="">123</accountId> 
       <pin xmlns="" >123</pin> 
      </account> 
      <amount> 
       <valueCode xmlns="">ZAR</valueCode> 
       <enteredAmount xmlns="">30</enteredAmount> 
       <nsfAllowed xmlns="">N</nsfAllowed> 
      </amount> 
      <lineItems> 
       <LineItem> 
        <productCode>1</productCode> 
        <categoryCode>1</categoryCode> 
        <qty>1</qty> 
        <price>50</price> 
        <discountedPrice>0</discountedPrice> 
        <description>Buffet Breakfast</description> 
       </LineItem> 
      </lineItems> 
     </p_objrequest> 
     <netCredentials> 
      <UserName xmlns="http://tempuri.org/">123</UserName> 
      <Password xmlns="http://tempuri.org/">123</Password> 
     </netCredentials> 
     </UpdateSale> 
    </soap:Body> 
</soap:Envelope> 

이상은 xml이며 netCredentials는 올바르게 직렬화 해제되지만 p_objrequest는 null로 제공됩니다.

이 문제를 경험하고 해결했다면 올바른 방향으로 이끌 수 있다면 정말 고맙겠습니다.

고맙습니다.

편집 아래

클래스

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.6.1055.0")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tokenws.netgen.co.za/")] 
    public class Sale 
    { 

     private int transactionTypeIdField; 

     private int tenderTypeIdField; 

     private RequestStandardHeaderComponent standardHeaderField; 

     private AccountComponent accountField; 

     private string activatingField; 

     private AmountComponent amountField; 

     private CustomerInfoComponent customerInfoField; 

     private PromotionCode[] promotionCodesField; 

     private QuestionAndAnswer[] questionsAndAnswersField; 

     private LineItem[] lineItemsField; 

     private string includeTipField; 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 0)] 
     public int transactionTypeId 
     { 
      get 
      { 
       return this.transactionTypeIdField; 
      } 
      set 
      { 
       this.transactionTypeIdField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 1)] 
     public int tenderTypeId 
     { 
      get 
      { 
       return this.tenderTypeIdField; 
      } 
      set 
      { 
       this.tenderTypeIdField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 2)] 
     public RequestStandardHeaderComponent standardHeader 
     { 
      get 
      { 
       return this.standardHeaderField; 
      } 
      set 
      { 
       this.standardHeaderField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 3)] 
     public AccountComponent account 
     { 
      get 
      { 
       return this.accountField; 
      } 
      set 
      { 
       this.accountField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 4)] 
     public string activating 
     { 
      get 
      { 
       return this.activatingField; 
      } 
      set 
      { 
       this.activatingField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 5)] 
     public AmountComponent amount 
     { 
      get 
      { 
       return this.amountField; 
      } 
      set 
      { 
       this.amountField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 6)] 
     public CustomerInfoComponent customerInfo 
     { 
      get 
      { 
       return this.customerInfoField; 
      } 
      set 
      { 
       this.customerInfoField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlArrayAttribute(Order = 7)] 
     public PromotionCode[] promotionCodes 
     { 
      get 
      { 
       return this.promotionCodesField; 
      } 
      set 
      { 
       this.promotionCodesField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlArrayAttribute(Order = 8)] 
     public QuestionAndAnswer[] questionsAndAnswers 
     { 
      get 
      { 
       return this.questionsAndAnswersField; 
      } 
      set 
      { 
       this.questionsAndAnswersField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlArrayAttribute(Order = 9)] 
     public LineItem[] lineItems 
     { 
      get 
      { 
       return this.lineItemsField; 
      } 
      set 
      { 
       this.lineItemsField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlElementAttribute(Order = 10)] 
     public string includeTip 
     { 
      get 
      { 
       return this.includeTipField; 
      } 
      set 
      { 
       this.includeTipField = value; 
      } 
     } 
    } 
+0

이 순서는 변경 될 수 있지만 주문을 전환 해 보셨습니까? 'UserName'보다'Password'를 앞두고 있습니까? – christophano

+0

수업을 봐야합니다. 속성이 공개가 아니거나 네임 스페이스 중 하나가 누락되었습니다. xmlns = "http://tokenws.netgen.co.za/"또는 "http://tempuri.org/" – jdweng

+0

@jdweng 클래스를 배치하여 게시물을 업데이 트했습니다. – Nathi

답변

0

경우를 포함 일치해야합니다 태그 이름과 클래스/속성 이름입니다. 아래를 참조하십시오 :

[XmlRoot(ElementName= "UpdateSale", Namespace="http://tokenws.netgen.co.za/")] 
    public class Sale 
    { 
    } 
    [XmlRoot(ElementName= "netCredentials")] 
    public class NetCredentials 
    { 
     [XmlElement(ElementName="UserName",Namespace="http://tempuri.org/")] 
     public Name userName { get; set;} 
     [XmlElement(ElementName="Password",Namespace="http://tempuri.org/")] 
     public Name password { get; set;} 
    } 
    public class Name 
    { 
     [XmlText] 
     public string name { get; set;} 
    }