简体   繁体   English

通过邮递员到wcf接收邮寄请求

[英]receiving post request through postman into wcf

I'm trying to receive an XML [post] message coming from Postman using WCF there are man things that I need to know first what type of data coming from rest is it for example Stream, XML, HttpRequest. 我试图使用WCF接收来自邮递员的XML [post]消息,我需要首先了解一些来自其余部分的数据类型,例如Stream,XML,HttpRequest。
I built this simple receiver but so far it's not working. 我建立了这个简单的接收器,但到目前为止它没有用。

    [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;
  }

also if Postman is sending Post to my project wouldn't my method become get type? 另外,如果邮递员将Post发送给我的项目,我的方法是否不会成为get类型?

how can I reach each tag inside the xml request and their respective values? 如何到达xml请求中的每个标签及其各自的值?

Postman Sending me this error 400 Encountered invalid root element name 'Messages'. 邮递员向我发送此错误400遇到无效的根元素名称“消息”。 'root' is the only allowed root element name. “ root”是唯一允许的根元素名称。

The type of the XmlEnity could not be serialized and deserialized properly in WCF. XmlEnity的类型无法在WCF中正确序列化和反序列化。 We had better use strong-typed data and decorate the custom class with DataContract attribute. 我们最好使用强类型的数据,并使用DataContract属性装饰自定义类。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/using-data-contracts https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/using-data-contracts
XML and JSON data format in SOAP message is implemented by the WCF framework itself. SOAP消息中的XML和JSON数据格式由WCF框架本身实现。

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

Please refer to the example in the reply. 请参考回复中的示例。
Get the object is null using JSON in WCF Service 在WCF服务中使用JSON获取对象为null
Feel free to let me know if there is anything I can help with. 请随时告诉我是否有什么我可以帮助的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM