1

调试 WCF - 对于我的生活,我无法弄清楚为什么我的服务方法返回 http 错误 400。DLL 部署在 IIS 中并且 SVC 指向它 - DLL 中的所有其他服务方法都可用并返回正确的数据。我在 IIS 的进程中附加了调试器,并且能够单步执行所有其他服务方法 - 但由于某种原因,调试器甚至没有捕获对此方法的调用。符号已正确加载。我什至尝试打破所有异常 - 它不想因任何原因在 GetCustomInquiries_POST 中停止,并且该服务仍然可用并在返回时显示 http 错误 400。有任何想法吗?我知道我在某个地方发胖了。

我有以下合同的服务:

    [OperationContract]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    Stream GetCustomInquiries_POST();

以及以下实现:

    public Stream GetCustomInquiries_POST()
    {
        // Returns a list of of business objects
        CustomInquiries customInquiries = WebSupport.DocumentInquiry.GetCustomInquiries();

        // Create an empty list of WCFCustomInquiry, which is a data
        // contract that exposes certain properties of a customInquiry.  
        // This list will be filled with all of the saved inquiries
        List<WCFCustomInquiry> customInquiriesToReturn = new List<WCFCustomInquiry>();

        // For each of the inquiries that were returned.
        foreach (CustomInquiry customInquiry in customInquiries)
        {

            // Create a list of properties exposed via the web service
            List<WCFProperty> savedProperties = new List<WCFProperty>();

            // For each of the properties in the saved inquiry, cast it to a WCFProperty, 
            // which is added to the list of properties exposed to the web service
            foreach (InquiryPropertyValue testProperty in customInquiry.SearchCriteria.Properties.Values)
            {
                WCFProperty savedProperty = new WCFProperty(testProperty.PropertyID, testProperty.Prompt, testProperty.DataType);
                savedProperty.inquirySearchText = testProperty.Value.ToString();
                savedProperty.inquirySearchType = testProperty.SearchType;
                savedProperties.Add(savedProperty);
            }


            // create a new webInquiryCriteria instance, which exposes the listed
            // properties to the web service.
            WCFInquiryCriteria webInquiryCriteria = new WCFInquiryCriteria(customInquiry.TopLevelFolders, customInquiry.DocTypes, customInquiry.SearchCriteria.DocumentTypes, customInquiry.SearchCriteria.TopLevelFolders, savedProperties, "", "", false, null, null);

            // Created an instance of the data-contract, using the members
            // to be exposed from the inquiry
            WCFCustomInquiry customInquiryToReturn = new WCFCustomInquiry(customInquiry.CustomInquiryId, customInquiry.Name, customInquiry.Description, customInquiry.AutoRun, customInquiry.DocTypes, customInquiry.TopLevelFolders, webInquiryCriteria, customInquiry.UserSuppliedProperties);

            // Add that new instance to the list that 
            customInquiriesToReturn.Add(customInquiryToReturn);
        }

        return WebSupport.JSONSerializationHelper.GetJSONStreamToReturn(customInquiriesToReturn);
    }
4

0 回答 0