通过控制器类从webservice返回对象返回一个空对象

时间:2013-03-17 19:24:50

标签: c# web-services object guid

我正在用我的数据库中的数据构建我的对象,到目前为止一直很好

    public static List<ImageData> GetAllImageData(Guid UserId)
    {
        List<ImageData> imageDataList = new List<ImageData>();
        try
        {
            SqlCommand cmd = DBHandler.getCommand("sp_Get_AllImagesForWebUser");
            DBHandler.AddParameter(ref cmd, "@UserId", UserId);
            foreach (DataRow row in DBHandler.ExecuteSP(cmd).Tables[0].Rows)
            {
                LogWriter.Print("imagedatacontroller() new Guid(row[ImageId].ToString()): " + new Guid(row["ImageId"].ToString()), LogLevel.DEBUG);
                imageDataList.Add(
                    new ImageData(new Guid(row["ImageId"].ToString()), new Guid(row["UserId"].ToString()), row["ImagePath"].ToString(), (int)row["PatientId"], row["BodyPart"].ToString(), row["ReasonForVisit"].ToString(), row["Diagnosis"].ToString(), Convert.ToBoolean(row["ConsentForResearch"]), Convert.ToBoolean(row["ConsentForEducation"]), Convert.ToBoolean(row["ConsentForStorage"]))
                    );
            }
        }
        catch (Exception e)
        {
            LogWriter.Print("Exception: ImageDataController->GetAllImageData() " + e, LogLevel.EXCEPTION);
        }
        return imageDataList;
    }

然后我有一个Web服务(.ASMX)公开该函数并返回ImageData的List

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public List<ImageData> GetImageDataFromUser(string UserId)
    {
        return ImageDataController.GetAllImageData(new Guid(UserId));
    }

但问题是ImageData的两个Guid属性(ImageId和UserId)是一个只有零值的Guid,我无法弄清楚为什么。我已经使用我的LogWriter验证了它是一个有效且正确的Guid,但是一旦我尝试通过我的webservice公开它只是一个零指南。

这就是我的SOAP的样子

<ArrayOfImageData xmlns="http://172.18.67.166:147/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <ImageData> 
        <ImageId>00000000-0000-0000-0000-000000000000</ImageId> 
        <UserId>00000000-0000-0000-0000-000000000000</UserId> 
        <ImagePath>C:\inetpub\wwwroot\Omegapoint\data\UploadedImages\0416f1aa-9b57-4ba8-be54-398ffa9d7139.PNG</ImagePath> 
        <PatientId>0</PatientId> 
        <CreationDate>2013-03-17T22:08:10.1964107+01:00</CreationDate> 
        <Bodypart/> 
        <ReasonForVisit/> 
        <Diagnosis/> 
        <ConsentForResearch>false</ConsentForResearch> 
        <ConsentForEducation>false</ConsentForEducation>
        <ConsentForStorage>false</ConsentForStorage> 
    </ImageData>
</ArrayOfImageData>

但ImageId应该是:

0416f1aa-9b57-4ba8-be54-398ffa9d7139

UserId应该是:

4bcd23a9-2815-42ef-b9ea-671b2aa08aa3 

0 个答案:

没有答案