1

I am building a SOAP Server with WCF in C#. I have an Request from a Client thats looks like that :

<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<sendLocalListRequest xmlns="urn://Ocpp/Cp/2012/06/">
  <updateType>Full</updateType>
  <listVersion>5678</listVersion>
  <localAuthorisationList>
    <idTag>1111111</idTag>
    <idTagInfo>
      <status>Accepted</status>
      <expiryDate>2015-10-27T00:00:00</expiryDate>
      <parentIdTag>555</parentIdTag>
    </idTagInfo>
  </localAuthorisationList>
  <localAuthorisationList>
    <idTag>2112432</idTag>
    <idTagInfo>
      <status>Accepted</status>
      <expiryDate>2015-10-29T00:00:00</expiryDate>
      <parentIdTag>555</parentIdTag>
    </idTagInfo>
  </localAuthorisationList>
  <localAuthorisationList>
    <idTag>44444444</idTag>
    <idTagInfo>
      <status>Accepted</status>
      <expiryDate>2015-10-29T00:00:00</expiryDate>
      <parentIdTag>2222</parentIdTag>
    </idTagInfo>
  </localAuthorisationList>
  <hash>bhghs77767676777</hash>
</sendLocalListRequest>

I have to get this Request and store the Data between the Elements localAuthorisationList in a file on harddisk. I made an [MessageContract] that Looks :

[MessageContract(IsWrapped = true, WrapperName = "sendLocalListRequest", 
WrapperNamespace = "urn://Ocpp/Cp/2012/06/")]    
public class sendLocalListRequest
{      
 [MessageBodyMember(Order=1)]
 public UpdateType updateType;

 [MessageBodyMember(Order=2)]
 public int listVersion;

 [MessageBodyMember(Order=3)]
 public localAuthorisation[] localAuthorisationList;

 [MessageBodyMember(Order=4)]
 public string hash;
}



[DataContract(Namespace = "urn://Ocpp/Cp/2012/06/")]

public class localAuthorisation 
{
 [DataMember(IsRequired=true, Name = "idTag", Order = 1)]
 public string idTag;

 [DataMember(Name="idTagInfo", Order=2)]
 public Data idTagInfo;
}


 [DataContract(Namespace = "urn://Ocpp/Cp/2012/06/")]
 public class Data 
{
 [DataMember(Name = "status", Order=1)]
 public string Status;

 [DataMember(Name = "expiryDate", Order=2)]
 public DateTime ExDate;

 [DataMember(Name = "parentIdTag", Order = 3)]
 public string parentTag;
}

But with the WCFTestClient I get the following Request :

<s:Body>
<sendLocalListRequest xmlns="urn://Ocpp/Cp/2012/06/">
  <updateType>Differential</updateType>
  <listVersion>0</listVersion>
  <localAuthorisationList xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <localAuthorisation>
      <idTag>sfdsdgfg</idTag>
      <idTagInfo>
        <ExDate>2015-11-02T16:37:00</ExDate>
      </idTagInfo>
    </localAuthorisation>
    <localAuthorisation />
    </localAuthorisationList>
   <hash i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
  </sendLocalListRequest>
</s:Body>

My problem is, that I have an element too much (localAuthorisationList or localAuthorisation). Can I eliminate one Element? And how?

Thank you for your help

Tom

Tom
  • 11
  • 2

0 Answers0