簡體   English   中英

通過郵遞員到wcf接收郵寄請求

[英]receiving post request through postman into wcf

我試圖使用WCF接收來自郵遞員的XML [post]消息,我需要首先了解一些來自其余部分的數據類型,例如Stream,XML,HttpRequest。
我建立了這個簡單的接收器,但到目前為止它沒有用。

    [WebInvoke(UriTemplate = "/PostMessage", Method = "POST")]
    public String InsertMessage(XmlEntity value)
    {
        String re = null;
        foreach (XmlNode node in value.ChildNodes)
        {
            string text = node.InnerText; 
            string tag = node.Name;

        }
    re = text;
  }

另外,如果郵遞員將Post發送給我的項目,我的方法是否不會成為get類型?

如何到達xml請求中的每個標簽及其各自的值?

郵遞員向我發送此錯誤400遇到無效的根元素名稱“消息”。 “ root”是唯一允許的根元素名稱。

XmlEnity的類型無法在WCF中正確序列化和反序列化。 我們最好使用強類型的數據,並使用DataContract屬性裝飾自定義類。
https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/using-data-contracts
SOAP消息中的XML和JSON數據格式由WCF框架本身實現。

    [WebInvoke(Method = "POST",
  ResponseFormat = WebMessageFormat.Xml,
   RequestFormat = WebMessageFormat.Xml,
  BodyStyle = WebMessageBodyStyle.WrappedRequest,
        UriTemplate ="BookInfo/")]

請參考回復中的示例。
在WCF服務中使用JSON獲取對象為null
請隨時告訴我是否有什么我可以幫助的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM