c# - WCF Service not returning data -
i have simple wcf project accepts xml string , parses xml build search object. search object used make calls referenced project calls sql stored procedure. results put class , class serialized xml , returned string wcf service. able debug wcf service starting , adding web reference project. in debug mode returns xml 14 records. published wcf service iis site , returns xml no records. search object there since parsed return referenced code has 0 records.
sample code below. seems execute performsearch code isn't returning results.
any ideas??
<?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> <!-- avoid disclosing metadata information, set values below false before deployment --> <servicemetadata httpgetenabled="true" httpsgetenabled="true"/> <!-- receive exception details in faults debugging purposes, set value below true. set false before deployment 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"/> <!-- browse web app root directory during debugging, set value below true. set false before deployment 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>(); }
add [servicecontract] attribute incsupplierservice interface , add [operationcontract] attribute
string processorder(string value);
property.
add [datacontract] attribute nccriminalresponse , add [datamember] attribute public properties.
Comments
Post a Comment