WCF服务丢失了来自客户端的呼叫日期

时间:2014-02-12 01:16:26

标签: c# asp.net-mvc vb.net wcf

我有一个为MVC应用程序提供服务的WCF服务。从客户端,我已经下载了一个具有日期属性的复杂对象。到目前为止都很好。我在视图中显示对象的数据,编辑其他属性并发布视图。在帖子上,模型调用服务上的方法以将对象发送到服务中进行处理。这是问题的起点。在服务方法中收到的日期/时间字段为空时为空。所有其他数据元素都很好。我在模型方法中检查了属性值,到目前为止它是正确的。在这种情况下,我发回的信息与我最初从服务中获得的值相同。

仅供参考,该服务是用VB编写的,MVC应用程序是用C#编写的。我无法弄清楚问题是什么。我已经检查了我能想到的一切,看起来都很好。欢迎所有建议!

根据要求编辑添加代码:

注意:该值最初是由客户端通过服务获取的,作为Tran_Issue类型的对象来自

在C#方法中检查的值SaveIssueTran():

?issue.IssuedOnDateTime

{11/25/2013 2:20:26 PM}     日期:{11/25/2013 12:00:00 AM}     第25天     DayOfWeek:星期一     DayOfYear:329     小时:14     种类:未指定     毫秒:0     分钟:20     月:11     第二:26     蜱虫:635209860260000000     TimeOfDay:{14:20:26}     年份:2013

在服务方法(VB.Net)的第一行代码中检查的值:

?issue.IssuedOnDateTime

12:00:00 AM

服务方法代码:

    Function SaveIssueTran(ByVal Issue As Tran_Issue, _
                       ByVal CurrentUserEmployeeID As String) As Tran_Issue _
                   Implements IROAMHostSvc.SaveIssueTran

    Dim messages As New Notification
    Try
        'validate the incoming xml tran data
        If Not Issue.Validate(messages) Then
            messages.RegisterMessage("Transaction details:", Issue.ToString)
            ROAMHostClassLib.LogMessages("Detail transaction validation errors for : " &     Issue.TransactionID, messages, True, True)
            Return Issue
        End If

        Return SaveDetailTransaction(Issue, CurrentUserEmployeeID)

    Catch ex As Exception
        messages.RegisterMessage("ROAMHostSvc.vb.SaveIssueTran()", ex.ToString)
        messages.RegisterMessage("Transaction details: ", Issue.ToString)
        ROAMHostClassLib.LogMessages("Error saving detail transaction object for         TransactionID " & Issue.TransactionID & _
                                     ", TransactionID " & Issue.TransactionID, messages, True, True)
        Issue.Messages = messages
        Return Issue
    End Try
End Function

调用服务方法的客户端方法:

        public static ROAMHostSvc.Tran_Issue SaveIssueTran(ROAMHostSvc.Tran_Issue issue, 
                                                        string currentUserEmployeeID)
    {
        ROAMHostSvc.ROAMHostSvcClient hostSvc = null;
        try
        {
            hostSvc = new ROAMHostSvc.ROAMHostSvcClient();
            issue = hostSvc.SaveIssueTran(issue, currentUserEmployeeID);
            return issue;
        }
        catch (Exception ex)
        {
            throw;
        }
        finally
        {
            CommonMethods.Close_WCF_Service(ref hostSvc);
        }
    }

Class Property(客户端上的OK,服务方法中为null):

    <DataMember()> _
Public Property IssuedOnDateTime As Date
    Get
        Return _issueDateTime
    End Get
    Set(ByVal value As Date)
        _issueDateTime = value
    End Set
End Property

对象声明:

<DataContract()> _
Public Class Tran_Issue
    Inherits TransactionDetailBase

最初从以下地址获取对象的服务方法:

Function GetIssueTran(ByVal BatchID As String, _
                        ByVal TransactionID As String) As Tran_Issue _
                    Implements IROAMHostSvc.GetIssueTran

    Dim issueTran As Tran_Issue
    issueTran = GetTranDetailObject(BatchID, TransactionID, TransactionTypes.Issue)
    Return issueTran
End Function

0 个答案:

没有答案