c# - Call to a WCF service, internal variables are NULL -
i've created wcf service running on network. when client tries phone call 1 of function (i'm debugging , checking step-by-step when phone call comes in), of variables defined in wcf service null (e.g logger class defined on service creation null).
i've tried search terms these, ends empty. have experience regarding issue? wcf service created on different thread server application.
edit:
client code:
[servicecontract] public interface iinterface { [operationcontract] string ping(); } public class interface : iinterface { public string ping() { logger.debug("interface received ping through wcf"); //exception, logger null homecoming "pong"; } public void openhost() { seek { logger.info("interface openhost - wcf thread initializing id:" + thread.currentthread.managedthreadid.tostring()); string machineaddress = string.format("{0}.{1}", system.net.dns.gethostname(),system.net.networkinformation.ipglobalproperties.getipglobalproperties().domainname); baseaddress = new uri(string.format("http://{0}:8732/wcf/",machineaddress) + "interface_" + system.diagnostics.process.getcurrentprocess().sessionid.tostring() + "_" + system.diagnostics.process.getcurrentprocess().id.tostring() + "/"); logger.info("interface openhost - wcf host started baseaddress " + baseaddress.tostring()); servicehost = new servicehost(typeof(interface), baseaddress); servicehost.addserviceendpoint(typeof(iinterface), new basichttpbinding(), baseaddress); servicehost.open(); logger.info("interface openhost - wcf host ready , listening incomming requests"); } grab (exception ex) { handleexception(ex, "openhost"); } } client code:
string swcfurl = wcfurl + "?wsdl"; //create object of binding system.servicemodel.channels.binding binding = new system.servicemodel.basichttpbinding(); //create endpointaddress of service system.servicemodel.endpointaddress endpointaddress = new system.servicemodel.endpointaddress(swcfurl); //create client of service interfaceservice.interfaceclient cc = new interfaceservice.interfaceclient(binding, endpointaddress); //call service method using serviceclient string ss = cc.ping();
wcf service should stateless possible. mean if want create logger class, suggest create static variable. other that, variables define should strictly local method. having said that, misinterpreting problem, code snippet help improve understand issue. if want initialize , have members in class may want take @ this: sessions, instancing , concurrency.
c# .net wcf
No comments:
Post a Comment