asp.net - Returning an output value via C# WCF service -


i'm looking return string value client via http post service on wcf.

i can return status code okay via following:

weboperationcontext.current.outgoingresponse.statuscode = httpstatuscode.ok;

... i'm not entirely sure how return string value client.

any pointers appreciated.

thanks

nick

namespace textwcf { [servicecontract] public interface ishortmessageservice {     [webinvoke(uritemplate = "invoke", method = "post", bodystyle = webmessagebodystyle.wrappedrequest)]     [operationcontract]     void postsms(stream input);  } }  [operationbehavior]     public void postsms(stream input)     {          streamreader sr = new streamreader(input);         string s = sr.readtoend();         sr.dispose();         namevaluecollection qs = httputility.parsequerystring(s);          string user = convert.tostring(qs["user"]);         string password = qs["password"];         string api_id = qs["api_id"];         string = qs["to"];         string text = qs["text"];         string = qs["from"];          weboperationcontext.current.outgoingresponse.statuscode = httpstatuscode.ok;         weboperationcontext.current.outgoingresponse. = httpstatuscode.ok;     } 

you need have method return neil pointed out.

so change method signature like

namespace textwcf { [servicecontract] public interface ishortmessageservice {     [webinvoke(uritemplate = "invoke", method = "post", bodystyle = webmessagebodystyle.wrappedrequest)]     [operationcontract]     string postsms(stream input);  } }  [operationbehavior]     public string postsms(stream input)     {          streamreader sr = new streamreader(input);         string s = sr.readtoend();         sr.dispose();         namevaluecollection qs = httputility.parsequerystring(s);          string user = convert.tostring(qs["user"]);         string password = qs["password"];         string api_id = qs["api_id"];         string = qs["to"];         string text = qs["text"];         string = qs["from"];          weboperationcontext.current.outgoingresponse.statuscode = httpstatuscode.ok;         weboperationcontext.current.outgoingresponse. = httpstatuscode.ok;          return "some string";     } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -