जब मैं एक वेब सेवा ऑपरेशन कहता हूं, डब्ल्यूसीएफ डेटाकंट्रैक्टसेरियलाइज़र के साथ प्रॉक्सी क्लास को संदेश deserializes: मैं ऐसा क्यों नहीं कर सकता?DataContractSerializer के साथ एक फ़ाइल से डब्ल्यूसीएफ साबुन प्रतिक्रिया संदेश deserialize कैसे?
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:PlotiIntf" xmlns:ns2="urn:PlotiIntf-IPloti" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<ns2:ActLoginResponse>
<return>
<ResultCode>0</ResultCode>
<ResultMessage>Login et password correct.</ResultMessage>
<Acteur>
<Id>IMT_706</Id>
<Nom>IMA PROTECT</Nom>
<Prenom/>
<nbFI>0</nbFI>
<FonctionActeur>TS</FonctionActeur>
<Timeout>30</Timeout>
</Acteur>
<ZneGeoList xsi:nil="true"/>
</return>
</ns2:ActLoginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
इसी ActLoginResponse वर्ग के लिए WCF प्रॉक्सी कोड है::
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="ActLoginResponse", WrapperNamespace="urn:PlotiIntf-IPloti", IsWrapped=true)]
public partial class ActLoginResponse {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
public Ploti.PlotiClient.LoginResponseType @return;
public ActLoginResponse() {
}
public ActLoginResponse(Ploti.PlotiClient.LoginResponseType @return) {
[email protected] = @return;
}
}
तो मैं एक करने के लिए XML पार्स करने के लिए की जरूरत है
यहाँ फ़ाइल ActLoginResponse.xml में साबुन संदेश है ActLoginResponse प्रकार का ऑब्जेक्ट उदाहरण।
यहाँ कैसे मैं पार्स प्रदर्शन है:
ActLoginResponse body;
FileStream stream = new FileStream("Requests\\ActLoginResponse.xml", FileMode.Open);
XmlReader xmlReader = XmlReader.Create(stream);
xmlReader.MoveToContent();
xmlReader.ReadStartElement();
xmlReader.MoveToContent();
xmlReader.ReadStartElement();
xmlReader.MoveToContent();
xmlReader.ReadStartElement();
xmlReader.MoveToContent();
// the the reader is on the element ActLoginResponse (that is confirmed by a Log.Debug(xmlReader.ReadOuterXml());
// I create The DataContractSerializer: exception if nampespace is not specified
DataContractSerializer dataContract = new `DataContractSerializer`(typeof(ActLoginResponse), "ActLoginResponse", "urn:PlotiIntf-IPloti");
ActLoginResponse actLogin = dataContract.ReadObject(xmlReader, true);
actLogin वस्तु बनाई गई है, लेकिन सामग्री actLogin.return allways शून्य है! क्या मैं कुछ भुल गया ?
आप LoginResponseType वर्ग के गुणों परिभाषित है? यदि नहीं तो यह xml से ऑब्जेक्ट में मानों को deserialize करने में सक्षम नहीं होगा। – Popo
हां सभी गुणों को परिभाषित किया गया है क्योंकि LoginResponseType एक वर्ग के रूप में डब्लूएसडीएल को संदर्भित करते समय उत्पन्न कक्षा है। जब मैं वेब सेवा का उपयोग करता हूं LoginResponseType नेटवर्क से प्राप्त SOAP प्रतिक्रियाओं से deserialized है। मैं एक फाइल से एक ही bu करना चाहता हूँ। – abreneliere
* एक डब्ल्यूसीएफ क्लाइंट webservice कॉल * से प्रतिक्रिया क्या है? क्या आपका मतलब डब्लूसीएफ सेवा प्रतिक्रिया है? –