jeudi 22 mai 2014

c# - créer un nouveau dictionnaire dans une enveloppe SOAP - Stack Overflow


Pretty basic question, but I can't seem to find the answer anywhere.


How do you specify a new instance of a Dictionary<string, string> in SOAP? Basically I have this envelope (ommitted envelope top level tag for readability):


<soapenv:Body>
<tem:LogInWithCredentials>
<tem:Request>
<ttf1:Password>password</ttf1:Password>
<ttf1:UserName>username</ttf1:UserName>
<ttf1:RequestInfo></ttf1:RequestInfo>
</tem:Request>
</tem:LogInWithCredentials>
</soapenv:Body>


RequestInfo is the property in question, but it's always null. I assumed that just the presence of the property in the envelope would be deserialized into an empty Dictionary<string, string>, however this is not the case.




As @flem says, the DataContractSerializer might provide the clues needed to answer this. Serializing an empty dictionary gives the following XML. Give that a try in your RequestInfo element and see if it works (I've not tested it myself).


<ArrayOfKeyValueOfstringstring 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />


Pretty basic question, but I can't seem to find the answer anywhere.


How do you specify a new instance of a Dictionary<string, string> in SOAP? Basically I have this envelope (ommitted envelope top level tag for readability):


<soapenv:Body>
<tem:LogInWithCredentials>
<tem:Request>
<ttf1:Password>password</ttf1:Password>
<ttf1:UserName>username</ttf1:UserName>
<ttf1:RequestInfo></ttf1:RequestInfo>
</tem:Request>
</tem:LogInWithCredentials>
</soapenv:Body>


RequestInfo is the property in question, but it's always null. I assumed that just the presence of the property in the envelope would be deserialized into an empty Dictionary<string, string>, however this is not the case.



As @flem says, the DataContractSerializer might provide the clues needed to answer this. Serializing an empty dictionary gives the following XML. Give that a try in your RequestInfo element and see if it works (I've not tested it myself).


<ArrayOfKeyValueOfstringstring 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

0 commentaires:

Enregistrer un commentaire