0

当我 Deserlize soap xml 时,我得到状态和令牌属性值 Null。我该如何解决这个问题。如何在模型中分配 xattribute 和 Xelement 值。如何在 wcf 服务中使用 xml serlize。

我在下面有肥皂 XML

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
  <ResponseId xmlns="http://www.googlr.com/DDDls/"/>
</soap:Header>  
  <soap:Body>
  <ns3:NotifRQ Status="winner" value="dfdfdfdf    
      xmlns:ns2="http://www.googlr.com/gggg/"                            
     xmlns:ns3="http://www.opentravel.org/OTA/2003/05/beta">
   </ns3:NotifRQ>
    </soap:Body>
    </soap:Envelope>

模型:

[DataContract(Name = "Envelope", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public class Envelope
{
    [DataMember(Name = "Body", Order = 0)]
    public EnvelopeBody Body;
}

[DataContract(Name = "Body", Namespace = "http://www.opentravel.org/OTA/2003/05/beta")]
public class EnvelopeBody
{
    [DataMember(Name = "OTA_HotelResNotifRQ")]
    public NotifRQ NotifRQ;

}

[DataContract(Name = "NotifRQ", Namespace = "http://www.opentravel.org/OTA/2003/05/beta")]
public class NotifRQ 
{
    [DataMember(Name = "Status")]
    public string Status;

    [DataMember(Name = "value")]
    public string value;
  }


[ServiceContract]
public interface IPush
{
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "Details", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    Ackn GetBookingDetails(Details obj);

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "Response", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
    Response GetResponse(Envelope respxml);
  }

如何对 xml 进行 serlize 以及如何获取 xatttibute 值?

4

0 回答 0