Question: I am pretty new to tikz. I need a request response message in tikz. I have attached the image. I need the image should be generated as shown in the attached figure.[![enter image description here](https://i.stack.imgur.com/vi3Qc.jpg)](https://i.stack.imgur.com/vi3Qc.jpg) I have tried a lot, but struck in between. Here is the source.

```
 \documentclass[12pt,a4paper,twoside]{report}
 \usetikzlibrary{shapes, arrows, positioning}
 \usepackage{pgfplots}
 \usepackage{tikz}
 \usetikzlibrary{patterns}
 \usepgfplotslibrary{groupplots}
 \pgfplotsset{compat=1.12}
 \begin{document}
 \begin{figure}
 \centering
 \begin{tikzpicture}[shape=rectangle, text width=2cm, minimum height=3cm, minimum width=2cm, node distance=5cm, align=center, ultra thick, color=black]
 \node [draw](sp) {Service Provider};
 \node [draw,right=of sp] (sc) {Service Consumer};
 \draw [->] (sp) -- node [right] {request service} (sc) ;
 \draw [->] (sc.west) +(0,-1em) coordinate (b1) -- (sp.east |- b1);
 \end{tikzpicture}
 \end{figure} 
 \end{document}

```

Answer: 
You're fairly close actually. First, you do of course need to have `\usepackage{tikz}` before `\usetikzlibrary{..}`.

As for the diagram, instead of having all those settings directly in the `tikzpicture` options, make a new style with `stylename/.style={<list of settings>}`, and apply that style to your two nodes. Because you had them like that, it seems they applied to the node with `request service` as well, which is why that node had a linebreak in it. Finally, place the `request`/`response for` nodes `above` the path, instead of `right`. I also shifted the first line up, in the same way you shifted the second one down. 

[![output of code](https://i.stack.imgur.com/0sJU0.png)](https://i.stack.imgur.com/0sJU0.png)

```
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
 mybox/.style={
   text width=2cm,
   minimum height=3cm,
   minimum width=2cm,
   node distance=5cm,
   align=center,
   ultra thick,
   draw},
 myarrow/.style={
   ->,
   >=stealth,
   thick
  }
]
\node [mybox](sp) {Service Provider};
\node [mybox,right=of sp] (sc) {Service Consumer};
\draw [myarrow] (sp.east) +(0,-1em) coordinate (b1) -- node [above] {response for service} (sc.west |- b1) ;
\draw [myarrow] (sc.west) +(0,1em) coordinate (b1) --node[above] {request for a service} (sp.east |- b1);
\end{tikzpicture}
\end{figure} 
\end{document}

```
Just to show how easy to do it with basic LaTeX:

```
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{old-arrows}
\usepackage[svgnames]{xcolor} 

\begin{document}
  \[ 
  \setlength{\fboxsep}{0pt} \setlength{\fboxrule}{0.8pt}\fcolorbox{DarkSeaGreen}{white}{\begin{tabular}{c}
        \\ Service\\ provided \\[3ex]
     \end{tabular}}
    \begin{matrix}
        \xrightarrow[]{\makebox[4cm]{\normalsize request for service}}\\[-1ex]
        \xleftarrow[{\makebox[4cm]{\normalsize response for service }}]{}
    \end{matrix}
   \fcolorbox{DarkSeaGreen}{white}{\begin{tabular}{c}
       \\ Service\\ assumed \\[3ex]
    \end{tabular}}\]%
\end{document}

```

[![enter image description here](https://i.stack.imgur.com/E1WkW.png)](https://i.stack.imgur.com/E1WkW.png)