java - C# trying to "get" from server -



java - C# trying to "get" from server -

so have tomcat server can send query such as... localhost:8080/anarchychatserver/anarchychatservlet?message=asdf&sendto=x&sendfrom=y run doget() in tomcat server, have nil in dopost() homecoming asdf x y in response body html. in c# trying build query string , send message such...

public string sendmessage(string message) { string url = ""; string response = "no server response."; using (var wb = new webclient()) { uribuilder baseuri = new uribuilder("localhost:8080/anarchychatserver/anarchychatservlet"); message = message.replace("&", "(ampersand)"); message = message.replace("?", "(questionmark)"); string querytoappend = "message=" + message; if (baseuri.query != null && baseuri.query.length > 1) baseuri.query = baseuri.query.substring(1) + "&" + querytoappend; else baseuri.query = querytoappend; url = baseuri.uri.tostring(); querytoappend = "sendto=" + sending; if (baseuri.query != null && baseuri.query.length > 1) baseuri.query = baseuri.query.substring(1) + "&" + querytoappend; else baseuri.query = querytoappend; url = baseuri.uri.tostring(); querytoappend = "sentfrom=" + account[0]; if (baseuri.query != null && baseuri.query.length > 1) baseuri.query = baseuri.query.substring(1) + "&" + querytoappend; else baseuri.query = querytoappend; url = baseuri.uri.tostring(); seek { response = wb.downloadstring(baseuri.uri); } grab (system.net.webexception) { } } homecoming response; }

ignore hideous code reuse , whatnot. query building seems work right if output "url" homecoming proper url query string, issue is when print out response after phone call has been made server says "no server response" initialized @ top of c# code. i'm wondering how can query server. insight helpful.

your first problem lack of protocol in uri. seek this:

uribuilder baseuri = new uribuilder("http://localhost:8080/anarchychatserver/anarchychatservlet");

by way... debug these issues in future, use:

catch (exception ex) { <- breakpoint here }

and examine ex. or turn on breaking on thrown clr exceptions in visual studio , debug code (or don't swallow exception). see this:

ignoring exceptions when debugging code not thought in general...

java c# tomcat server

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -