c# - error calling method from WCF Restfull Service - ERR_CONNECTION_RESET -
i'm facing problem wcf restfull webservice, problem 1 method others working correctly, think isn't general configuration problem. have idea of problem don't know how solve it. method have access third party webservice retrieve object of following class:
[datacontract] public class devicedata { [datamember] public int devicedatafull { get; set; } [datamember] public string devicedataversion { get; set; } [datamember] public string devicedatamodel { get; set; } [datamember] public int devicedatazwave_heal { get; set; } [datamember] public string devicedatatemperature { get; set; } [datamember] public string devicedataskin { get; set; } [datamember] public string devicedataserial_number { get; set; } [datamember] public string devicedatafwd1 { get; set; } [datamember] public string devicedatafwd1token { get; set; } [datamember] public string devicedatafwd2 { get; set; } [datamember] public string devicedatafwd2token { get; set; } [datamember] public int devicedatamode { get; set; } [datamember] public list<section> devicedatasections { get; set; } [datamember] public list<room> devicedatarooms { get; set; } [datamember] public list<scene> devicedatascenes { get; set; } [datamember] public list<deviceitem> devicedataitems { get; set; } [datamember] public list<category> devicedatacategories { get; set; } [datamember] public int devicedatair { get; set; } [datamember] public string devicedatairtx { get; set; } [datamember] public int devicedataloadtime { get; set; } [datamember] public int devicedatastate { get; set; } [datamember] public string devicedatacomment { get; set; } }
the thing did in method's code fill object, in piece of code i'm trying the: public list<deviceitem> devicedataitems { get; set; }
problem because test method without , work perfectly. list of deviceitem have objects of inherit classes of device item:
deviceitempanel : deviceitem deviceitempanelpartition : deviceitem deviceitemdimmable : deviceitem deviceitemthermostat : deviceitem etc..
my question: there restriction in service architecture return class of object explaining above? because when execute method remain load , after few seconds message: err_connection_reset, don't see other error code or else, debug method , work fine problem when try return object json format. if 1 me find solution appreciate lot. note code of webservice method:
public resultdevicedata getdevicedata(string user, string password, string devicenumber) { resultdevicedata result = new resultdevicedata(); try { identity identity = getuseridentityprivate(user, password); deviceinfo info = getdeviceinfobynumber(user, password, devicenumber); string url = "https://" + info.deviceinfoserverrelay + "/relay/relay/relay/device/" + info.devicenumber + "/port_3480/data_request?id=lu_sdata&output_format=json"; string jsonresult = request_get(url, null, null, info.deviceinfoserverrelaytoken); //read json var obj = jobject.parse(jsonresult); devicedata data = new devicedata(); data.devicedatafull = (int)obj.selecttoken("full"); data.devicedataversion = (string)obj.selecttoken("version"); data.devicedatamodel = (string)obj.selecttoken("model"); data.devicedatazwave_heal = (int)obj.selecttoken("zwave_heal"); data.devicedatatemperature = (string)obj.selecttoken("temperature"); data.devicedataskin = (string)obj.selecttoken("skin"); data.devicedataserial_number = (string)obj.selecttoken("serial_number"); data.devicedatafwd1 = (string)obj.selecttoken("fwd1"); data.devicedatafwd1token = request_get("https://" + data.devicedatafwd1 + "/info/session/token", identity.identityfirm, identity.identitysignature, null); data.devicedatafwd2 = (string)obj.selecttoken("fwd2"); data.devicedatafwd2token = request_get("https://" + data.devicedatafwd2 + "/info/session/token", identity.identityfirm, identity.identitysignature, null); data.devicedatamode = (int)obj.selecttoken("mode"); data.devicedatair = (int)obj.selecttoken("ir"); data.devicedatairtx = (string)obj.selecttoken("irtx"); data.devicedataloadtime = (int)obj.selecttoken("loadtime"); data.devicedatastate = (int)obj.selecttoken("state"); data.devicedatacomment = (string)obj.selecttoken("comment"); data.devicedatasections = new list<section>(); data.devicedatarooms = new list<room>(); data.devicedatascenes = new list<scene>(); data.devicedatacategories = new list<category>(); data.devicedataitems = new list<deviceitem>(); //loading sections var sections = jarray.parse(obj.selecttoken("sections").tostring()); (int = 0; < sections.count; i++) { section section = new section(); section.sectionid = (int)sections[i].selecttoken("id"); section.sectionname = (string)sections[i].selecttoken("name"); data.devicedatasections.add(section); } //loading rooms var rooms = jarray.parse(obj.selecttoken("rooms").tostring()); (int = 0; < rooms.count; i++) { room room = new room(); room.roomid = (int)rooms[i].selecttoken("id"); room.roomname = (string)rooms[i].selecttoken("name"); room.sectionid = (int)rooms[i].selecttoken("section"); data.devicedatarooms.add(room); } //loading scenes var scenes = jarray.parse(obj.selecttoken("scenes").tostring()); (int = 0; < scenes.count; i++) { scene scene = new scene(); scene.sceneid = (int)scenes[i].selecttoken("id"); scene.scenename = (string)scenes[i].selecttoken("name"); scene.roomid = (int)scenes[i].selecttoken("room"); scene.sceneactive = ((int)scenes[i].selecttoken("active")) != 0; data.devicedatascenes.add(scene); } //loading categories var categories = jarray.parse(obj.selecttoken("categories").tostring()); (int = 0; < categories.count; i++) { category category = new category(); category.categoryid = (int)categories[i].selecttoken("id"); category.categoryname = (string)categories[i].selecttoken("name"); data.devicedatacategories.add(category); } //loading devices var deviceitems = jarray.parse(obj.selecttoken("devices").tostring()); (int = 0; < deviceitems.count; i++) { int deviceitemid = (int)deviceitems[i].selecttoken("id"); string deviceitemaltid = (string)deviceitems[i].selecttoken("altid"); string deviceitemname = (string)deviceitems[i].selecttoken("name"); int roomid = (int)deviceitems[i].selecttoken("room"); int categoryid = (int)deviceitems[i].selecttoken("category"); int subcategoryid = (int)deviceitems[i].selecttoken("subcategory"); int deviceitemparent = (int)deviceitems[i].selecttoken("parent"); switch (categoryid) { case 1: { break; } case 2: { deviceitemdimmable dimmable = new deviceitemdimmable(); dimmable.deviceitemid = deviceitemid; dimmable.deviceitemaltid = deviceitemaltid; dimmable.deviceitemname = deviceitemname; dimmable.roomid = roomid; dimmable.categoryid = categoryid; dimmable.subcategoryid = 0; dimmable.deviceitemparent = deviceitemparent; dimmable.deviceitemdimmablestatus = (string)deviceitems[i].selecttoken("status"); dimmable.deviceitemdimmablelevel = (string)deviceitems[i].selecttoken("level"); dimmable.deviceitemdimmablestate = (int)deviceitems[i].selecttoken("state"); dimmable.deviceitemdimmablecomment = (string)deviceitems[i].selecttoken("comment"); data.devicedataitems.add(dimmable); break; } case 3: { break; } case 4: { break; } case 5: { switch (subcategoryid) { case 1: { deviceitemthermostat thermostat = new deviceitemthermostat(); thermostat.deviceitemid = deviceitemid; thermostat.deviceitemaltid = deviceitemaltid; thermostat.deviceitemname = deviceitemname; thermostat.roomid = roomid; thermostat.categoryid = categoryid; thermostat.subcategoryid = 0; thermostat.deviceitemparent = deviceitemparent; thermostat.deviceitemthermostatfanmode = (string)deviceitems[i].selecttoken("fanmode"); thermostat.deviceitemthermostathvacstate = (string)deviceitems[i].selecttoken("hvacstate"); thermostat.deviceitemthermostatmode = (string)deviceitems[i].selecttoken("mode"); thermostat.deviceitemthermostatsetpoint = (string)deviceitems[i].selecttoken("setpoint"); thermostat.deviceitemthermostatheat = (string)deviceitems[i].selecttoken("heat"); thermostat.deviceitemthermostatcool = (string)deviceitems[i].selecttoken("cool"); thermostat.deviceitemthermostatstatus = (string)deviceitems[i].selecttoken("status"); thermostat.deviceitemthermostatbatterylevel = (string)deviceitems[i].selecttoken("batterylevel"); thermostat.deviceitemthermostattemperature = (string)deviceitems[i].selecttoken("temperature"); thermostat.deviceitemthermostatstate = (int)deviceitems[i].selecttoken("state"); thermostat.deviceitemthermostatcomment = (string)deviceitems[i].selecttoken("comment"); data.devicedataitems.add(thermostat); break; } case 2: { break; } case 3: { break; } default: break; } break; } case 6: { deviceitemcamera camera = new deviceitemcamera(); camera.deviceitemid = deviceitemid; camera.deviceitemaltid = deviceitemaltid; camera.deviceitemname = deviceitemname; camera.roomid = roomid; camera.categoryid = categoryid; camera.subcategoryid = 0; camera.deviceitemparent = deviceitemparent; camera.deviceitemcameraip = (string)deviceitems[i].selecttoken("ip"); camera.deviceitemcameraurl = (string)deviceitems[i].selecttoken("url"); camera.deviceitemcamerastreamming = (string)deviceitems[i].selecttoken("streaming"); camera.deviceitemcameravideourl = (string)deviceitems[i].selecttoken("videourls"); camera.deviceitemcameracommands = ((string)deviceitems[i].selecttoken("commands")).split(','); data.devicedataitems.add(camera); break; } case 22: { deviceitempanel panel = new deviceitempanel(); panel.deviceitemid = deviceitemid; panel.deviceitemaltid = deviceitemaltid; panel.deviceitemname = deviceitemname; panel.roomid = roomid; panel.categoryid = categoryid; panel.subcategoryid = 0; panel.deviceitemparent = deviceitemparent; data.devicedataitems.add(panel); break; } case 23: { deviceitempanelpartition panelpartition = new deviceitempanelpartition(); panelpartition.deviceitemid = deviceitemid; panelpartition.deviceitemaltid = deviceitemaltid; panelpartition.deviceitemname = deviceitemname; panelpartition.roomid = roomid; panelpartition.categoryid = categoryid; panelpartition.subcategoryid = 0; panelpartition.deviceitemparent = deviceitemparent; panelpartition.deviceitempanelpartitionalarm = (string)deviceitems[i].selecttoken("alarm"); panelpartition.deviceitempanelpartitionalarmmemory = (string)deviceitems[i].selecttoken("alarmmemory"); panelpartition.deviceitempanelpartitionarmmode = (string)deviceitems[i].selecttoken("armmode"); panelpartition.deviceitempanelpartitiondetailedarmmode = (string)deviceitems[i].selecttoken("detailedarmmode"); data.devicedataitems.add(panelpartition); break; } default: { } break; } } result.resultmessage = "data retrieve"; result.resultobject = data; result.resultvalue = true; } catch (exception e) { result.resultmessage = e.message; result.resultobject = null; result.resultvalue = false; } return result; }
i solved problem returning string in method, , serializing object inside code.
return jsonconvert.serializeobject(result);
Comments
Post a Comment