How i get this diagram with Tikz?
2 Answers
OK, since @Andrew asked me to, I post an answer. (Originally I thought it is a bit pointless because the posts here are public such that others can learn from them. But there is not much one can learn from the following code, I think.)
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[block/.style={draw,minimum width=2cm,minimum height=1cm}, font=\sffamily]
\node[block](C) {Client};
\node[block,right=9cm of C](S) {Server};
\draw[-latex] (C.15) -- (S.165)
node[midway,above]{Request(GET,POST,PUT,DELETE,HEAD,OPTION)};
\draw[-latex] (S.195) -- (C.-15) node[midway,below]{Response(z.B.\ JSON,XML)};
\end{tikzpicture}
\end{document}
Here are some general comments. Notice that these are not meant to be harsh criticisms, but I would kindly like to ask you to read and think about this: in a previous question of yours, you had an MWE, which by itself is a good thing. However, this MWE had a very strong resemblance with a code by another author, which made me think that there is a chance that you copied it from the earlier post. Copying code from somewhere is IMHO fine as long as you give credit to the original author. If you don't, this makes some users here, including myself, a bit unhappy. Yet the solution is IMHO not just not to post an MWE because this then makes potential answerers just punch in stuff from a screen shot, which many dislike. Rather, I'd suggest that you may want to use previous answers, try to understand them and modify them to your needs, and if you get stuck, you have an MWE, which, if posted along with its source, will lead to a question which will trigger a much more favorable feedback. And this will then also lead to posts others can learn from.
Just for fun with MetaFun.
\startMPinclusions
input rboxes;
\stopMPinclusions
\startMPpage
numeric u; u := 1cm;
interim defaultdx := .5u;
interim defaultdy := .5u;
boxit.c("Client"); c.c = (-6.5u,0);
boxit.s("Server"); s.c = (+6.5u,0);
drawboxed(c,s);
path p,q;
p := .5[c.ne,c.e] -- .5[s.nw,s.w];
q := .5[s.sw,s.w] -- .5[c.se,c.e];
drawarrow p;
drawarrow q;
label.top("Request(GET,POST,PUT,DELETE,HEAD,OPTION)", point .5 along p);
label.bot("Response(z.B.\ JSON,XML)", point .5 along q);
\stopMPpage
- 109,596



\documentclass[tikz,border=3.14mm]{standalone} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[block/.style={draw,minimum width=2cm,minimum height=1cm}, font=\sffamily] \node[block](C) {Client}; \node[block,right=9cm of C](S) {Server}; \draw[-latex] (C.15) -- (S.165) node[midway,above]{Request(GET,PUT,\dots)}; \draw[-latex] (S.195) -- (C.-15) node[midway,below]{Response(\dots)}; \end{tikzpicture} \end{document}– Nov 20 '18 at 21:54