在RESTful WCF服务中不读取输入xml中的某些节点 [英] Some nodes in the input xml are not read in RESTful WCF service

查看:72
本文介绍了在RESTful WCF服务中不读取输入xml中的某些节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试通过Rest WCF请求接收XML参数。我输入的xml节点是:

Hi,

I am trying to receive an XML parameter, through Rest WCF request. my input xml node is this:

<RequestData  xmlns='RequestXML'>
    <market>Global</market>
  <gender>Female</gender>
    <stattype>None</stattype>
    <section>Profile</section>
    <viewoption>Total</viewoption>
    <mission>Total</mission>
    <group>Category Penetration - Overall</group>
    <filter>Total Sample</filter>
    <chartmode>Profiling</chartmode>
    <viewpage>Normal</viewpage>
    <samplefilter></samplefilter>
</RequestData>







It读入类:




It is read into a class :

[DataContract(Namespace = "RequestXML")]
public class RequestData
   {
       [DataMember]
       public string market { get; set; }
       [DataMember]
       public string gender { get; set; }
       [DataMember]
       public string stattype { get; set; }
       [DataMember]
       public string section { get; set; }
       [DataMember]
       public string viewoption { get; set; }
       [DataMember]
       public string mission { get; set; }
       [DataMember]
       public string group { get; set; }
       [DataMember]
       public string filter { get; set; }
       [DataMember]
       public string chartmode { get; set; }
       [DataMember]
       public string viewpage { get; set; }
       [DataMember]
       public string samplefilter { get; set; }

   }





现在当我读到这个请求时,收到的参数很少,很少没有。例如:参数:市场,stattype,viewpage总是被接收,因为其余的总是为空。



这是界面





Now when I read this request, few parameters are received and few are not. eg: parameters : market,stattype,viewpage are always received where as rest of them are always null.

Here is the interface

[OperationContract]
       //attribute for returning JSON format
       [WebInvoke(Method = "POST",
           ResponseFormat = WebMessageFormat.Json,
           RequestFormat= WebMessageFormat.Xml,
           BodyStyle = WebMessageBodyStyle.WrappedResponse,
           UriTemplate = "ProfileData")]
       //method
       List<ProfileData> GenProfileData(RequestData xmlRequestString);





我希望我的问题很清楚。希望快速回复



I hope my questions is clear. Hoping for a quick response

推荐答案

我建​​议你使用 Fiddler [ ^ ]甚至是IE开发者工具栏,检查是否有xml值发送到网络服务。



然后你可以确定发送了正确的数据,并且请求本身没有问题。



如果这是正确的,下一步将是使用Visual Studio并调试您在Web服务器上收到的内容并进入构造函数(或方法)。我希望到现在为止,你应该已经看到了什么问题。
I would suggest you to use Fiddler[^] or even IE developer toolbar to check if what xml values are being sent to the web service.

Then you can be atleast sure that the correct data is sent and there is not issue with the request itself.

If this correct, next step would be to use Visual Studio and debug what do you receive on the web server and step into the constructor (or method). I hope by now, you should already see what's going wrong.


这篇关于在RESTful WCF服务中不读取输入xml中的某些节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆