0
我有一個簡單的WCF項目,它接受XML作爲字符串並解析XML以構建搜索對象。然後搜索對象用於調用調用SQL存儲過程的引用項目。然後將結果放入一個類中,並將該類序列化爲XML,並通過WCF服務將其作爲字符串返回。我能夠通過啓動它並通過另一個項目添加它作爲Web引用來調試WCF服務。在調試模式下,它返回帶有14條記錄的XML。然後,我將WCF服務發佈到IIS站點,並返回XML但沒有記錄。搜索對象在那裏,因爲它只是被解析,但是被引用代碼的返回值有0個記錄。WCF服務不返回數據
示例代碼如下。所有似乎都執行但PerformSearch代碼不返回結果。
任何想法??
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
public class NCSupplierService : INCSupplierService
{
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
public string ProcessOrder(string value)
{
try
{
XmlDocument oDoc = new XmlDocument();
oDoc.LoadXml(value);
string Login = oDoc.SelectSingleNode("NCCriminal/login/user").InnerText.Trim();
string Password = oDoc.SelectSingleNode("NCCriminal/login/password").InnerText.Trim();
XmlNode OrderFields = oDoc.SelectSingleNode("NCCriminal/product/Statewide/order");
int SolutionID = Int32.Parse(oDoc.SelectSingleNode("NCCriminal").Attributes["referenceKey"].Value);
string FirstName = OrderFields.SelectSingleNode("firstName").InnerText.Trim();
string MiddleName = OrderFields.SelectSingleNode("middleName").InnerText.Trim();
string LastName = OrderFields.SelectSingleNode("lastName").InnerText.Trim();
int dobmonth = Int32.Parse(OrderFields.SelectSingleNode("DOB/month").InnerText.Trim());
int dobday = Int32.Parse(OrderFields.SelectSingleNode("DOB/day").InnerText.Trim());
int dobyear = Int32.Parse(OrderFields.SelectSingleNode("DOB/year").InnerText.Trim());
string SSN = OrderFields.SelectSingleNode("SSN").InnerText.Trim();
string Gender = OrderFields.SelectSingleNode("Gender").InnerText.Trim();
string Race = OrderFields.SelectSingleNode("Race").InnerText.Trim();
string License = OrderFields.SelectSingleNode("DriversLicense/license").InnerText.Trim();
string LicenseState = OrderFields.SelectSingleNode("DriversLicense/state").InnerText.Trim();
bool LimitToToDay = oDoc.SelectSingleNode("NCCriminal/product/Statewide/options/LimitToToday").InnerText.Trim() == "NO" ? false : true;
string ErrorMessage = string.Empty;
NCSearchTerms SearchTerms = new NCSearchTerms(LastName, FirstName, MiddleName, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, Gender, Race, new DateTime(dobyear, dobmonth, dobday).ToShortDateString(), SSN, new Datastructure.BaseClasses.DriversLicenseType(SolutionID, License, LicenseState));
NCSearch search = new NCSearch(SearchTerms, SolutionID);
if(!search.PerformSearch(ref search, SolutionID, LimitToToDay, out ErrorMessage))
throw new Exception(ErrorMessage);
if (!string.IsNullOrEmpty(ErrorMessage))
throw new Exception(ErrorMessage);
NCCriminalResponse response = new NCCriminalResponse();
response.SolutionID = SolutionID;
response.SearchTerms = SearchTerms;
response.RecordCount = search.SearchResults.SearchResults.Count();
response.DemographicCaseRecords = search.SearchResults.SearchResults;
StringBuilder sb = new StringBuilder();
sb.Append(SerializeXML.SerializeObject(response));
return sb.ToString();
}
catch (Exception Ex)
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-16\"?>");
sb.Append("<NCCriminalResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
sb.Append("<ProcessingError>");
sb.Append("<ErrorMessage>");
sb.Append(Ex.Message);
sb.Append("</ErrorMessage>");
sb.Append("</ProcessingError>");
sb.Append("</NCCriminalResponse>");
return sb.ToString();
}
}
}
//-----------------------------------------------------------------------------------
public class NCCriminalResponse
{
public int SolutionID;
public NCSearchTerms SearchTerms;
public int RecordCount = 0;
public List<DemographicCase> DemographicCaseRecords = new List<DemographicCase>();
}