WCF数据合同XML

时间:2016-04-11 22:09:38

标签: c# xml wcf datacontract

我在WCF相当新,我正在尝试编写一个接收xml消息的服务,(抱歉这里含糊不清)然后我需要根据XML内容做一堆任务。

以前这是一个接受字符串并将其转换为XML的ASMX服务,但现在我们正在转向WCF我需要创建一个数据合同,这就是我在下面的XML格式中遇到的绊脚

<SRREQUEST>
<GENERATED_DATE>2016-02-21T14:23:54</GENERATED_DATE>
<SYSTEMID>xxxx</SYSTEMID>
<SERVICEREQUEST>
    <SR_NUMBER>xxxx</SR_NUMBER>
    <CUSTOMER_ACCT>xxxx</CUSTOMER_ACCT>
    <CONTACT_ID>xxxx</CONTACT_ID>
    <CONTACT_NAME>xxxx</CONTACT_NAME>
    <CONTACT_EMAIL>xxxx</CONTACT_EMAIL>
    <END_USER_NAME>xxxx</END_USER_NAME>
    <END_USER_EMAIL>xxxx</END_USER_EMAIL>
    <END_USER_PHONE>xxxx</END_USER_PHONE>
    <SITENAME>xxxx</SITENAME>
    <ADDRESS_1>xxxx</ADDRESS_1>
    <ADDRESS_2>xxxx</ADDRESS_2>
    <CITY>xxxx</CITY>
    <COUNTRY>xxxx</COUNTRY>
    <POSTCODE>xxxx</POSTCODE>
    <SR_TYPE>xxxx</SR_TYPE>
    <RETURN_REASON>xxxx</RETURN_REASON>
    <WARRANTY_TYPE>xxxx</WARRANTY_TYPE>
    <RETURN_TYPE>xxxx</RETURN_TYPE>
    <PRIORITY>xxxx</PRIORITY>
    <ORIGIN>xxxx</ORIGIN>
    <CUST_REF>xxxx</CUST_REF>
    <CUST_COMMENTS>xxxx</CUST_COMMENTS>
    <CUST_UPDATE>xxxx</CUST_UPDATE>
    <BRAND>xxxx</BRAND>
    <TYPE>xxxx</TYPE>
    <MODEL>xxxx</MODEL>
    <ASSET_TAG>xxxx</ASSET_TAG>
    <SERIAL_NUMBER>xxxx</SERIAL_NUMBER>
    <ORDER_REF_NUM>xxxx</ORDER_REF_NUM>
    <ORDER_NUMBER>xxxx</ORDER_NUMBER>
</SERVICEREQUEST>
</SRREQUEST>

此XML可以有多个SERVICEREQUEST标记

目前我有这个OperationContract

[OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml)]
    string ServiceRequest(ServiceRequest data);

但我的datacontract是空的

所以这将是一个有多个服务请求的例子

<SRREQUEST>
 <GENERATED_DATE>2016-02-21T14:23:54</GENERATED_DATE>
 <SYSTEMID>xxxx</SYSTEMID>
 <SERVICEREQUEST>
     <SR_NUMBER>xxxx</SR_NUMBER>
     <CUSTOMER_ACCT>xxxx</CUSTOMER_ACCT>
     <CONTACT_ID>xxxx</CONTACT_ID>
     <CONTACT_NAME>xxxx</CONTACT_NAME>
     <CONTACT_EMAIL>xxxx</CONTACT_EMAIL>
     <END_USER_NAME>xxxx</END_USER_NAME>
     <END_USER_EMAIL>xxxx</END_USER_EMAIL>
     <END_USER_PHONE>xxxx</END_USER_PHONE>
     <SITENAME>xxxx</SITENAME>
     <ADDRESS_1>xxxx</ADDRESS_1>
     <ADDRESS_2>xxxx</ADDRESS_2>
     <CITY>xxxx</CITY>
     <COUNTRY>xxxx</COUNTRY>
     <POSTCODE>xxxx</POSTCODE>
     <SR_TYPE>xxxx</SR_TYPE>
     <RETURN_REASON>xxxx</RETURN_REASON>
     <WARRANTY_TYPE>xxxx</WARRANTY_TYPE>
     <RETURN_TYPE>xxxx</RETURN_TYPE>
     <PRIORITY>xxxx</PRIORITY>
     <ORIGIN>xxxx</ORIGIN>
     <CUST_REF>xxxx</CUST_REF>
     <CUST_COMMENTS>xxxx</CUST_COMMENTS>
     <CUST_UPDATE>xxxx</CUST_UPDATE>
     <BRAND>xxxx</BRAND>
     <TYPE>xxxx</TYPE>
     <MODEL>xxxx</MODEL>
     <ASSET_TAG>xxxx</ASSET_TAG>
     <SERIAL_NUMBER>xxxx</SERIAL_NUMBER>
     <ORDER_REF_NUM>xxxx</ORDER_REF_NUM>
     <ORDER_NUMBER>xxxx</ORDER_NUMBER>
 </SERVICEREQUEST>
 <SERVICEREQUEST>
     <SR_NUMBER>xxxx</SR_NUMBER>
     <CUSTOMER_ACCT>xxxx</CUSTOMER_ACCT>
     <CONTACT_ID>xxxx</CONTACT_ID>
     <CONTACT_NAME>xxxx</CONTACT_NAME>
     <CONTACT_EMAIL>xxxx</CONTACT_EMAIL>
     <END_USER_NAME>xxxx</END_USER_NAME>
     <END_USER_EMAIL>xxxx</END_USER_EMAIL>
     <END_USER_PHONE>xxxx</END_USER_PHONE>
     <SITENAME>xxxx</SITENAME>
     <ADDRESS_1>xxxx</ADDRESS_1>
     <ADDRESS_2>xxxx</ADDRESS_2>
     <CITY>xxxx</CITY>
     <COUNTRY>xxxx</COUNTRY>
     <POSTCODE>xxxx</POSTCODE>
     <SR_TYPE>xxxx</SR_TYPE>
     <RETURN_REASON>xxxx</RETURN_REASON>
     <WARRANTY_TYPE>xxxx</WARRANTY_TYPE>
     <RETURN_TYPE>xxxx</RETURN_TYPE>
     <PRIORITY>xxxx</PRIORITY>
     <ORIGIN>xxxx</ORIGIN>
     <CUST_REF>xxxx</CUST_REF>
     <CUST_COMMENTS>xxxx</CUST_COMMENTS>
     <CUST_UPDATE>xxxx</CUST_UPDATE>
     <BRAND>xxxx</BRAND>
     <TYPE>xxxx</TYPE>
     <MODEL>xxxx</MODEL>
     <ASSET_TAG>xxxx</ASSET_TAG>
     <SERIAL_NUMBER>xxxx</SERIAL_NUMBER>
     <ORDER_REF_NUM>xxxx</ORDER_REF_NUM>
     <ORDER_NUMBER>xxxx</ORDER_NUMBER>
 </SERVICEREQUEST>
 </SRREQUEST>

任何帮助都将不胜感激。

0 个答案:

没有答案