<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
        LINE-HEIGHT: 1.5; FONT-FAMILY: &#23435;&#20307;; COLOR: #000000; FONT-SIZE: 10.5pt
}
</STYLE>

<META name=GENERATOR content="MSHTML 8.00.7601.17940"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi all,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I wrote a sample code to use Rabbitmq management HTTP API. For "Create a 
new vhost", it works fine.</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;HttpPut&nbsp;httpput&nbsp;httpput&nbsp;=&nbsp;new&nbsp;HttpPut();</DIV>
<DIV 
style="TEXT-INDENT: 2em">httpput.setHeader("content-type",&nbsp;"application/json");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;httpput.setURI(new&nbsp;URI("<A 
href="http://192.168.2.129:55672/api/vhosts/my-vhost">http://192.168.2.129:55672/api/vhosts/my-vhost</A>"));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;DefaultHttpClient&nbsp;httpclient&nbsp;=&nbsp;new&nbsp;DefaultHttpClient();&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;httpclient.getCredentialsProvider().setCredentials(new&nbsp;AuthScope("192.168.2.129",&nbsp;55672),</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;UsernamePasswordCredentials("guest",&nbsp;"guest"));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;HttpResponse&nbsp;response&nbsp;=&nbsp;httpclient.execute(httpput);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>But if I want to create a new Exchange or Queue using the same code, it 
always returns NoHTTPResponseException. It seems that once I setEntity for 
httpput, the exception occurs.</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;HttpPut&nbsp;httpput 
=&nbsp;new&nbsp;HttpPut();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;httpput.setHeader("content-type",&nbsp;"application/json");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;JSONObject&nbsp;param&nbsp;=&nbsp;new&nbsp;JSONObject();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;param.put("type",&nbsp;"direct");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;StringEntity&nbsp;&nbsp;entity&nbsp;=&nbsp;new&nbsp;StringEntity(param.toString());</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;httpput.setEntity(entity);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;httpput.setURI(new&nbsp;URI("<A 
href="http://192.168.2.129:55672/api/exchanges/%2f/my-new-exchange">http://192.168.2.129:55672/api/exchanges/%2f/my-new-exchange</A>"));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;DefaultHttpClient&nbsp;httpclient&nbsp;=&nbsp;new&nbsp;DefaultHttpClient();&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;httpclient.getCredentialsProvider().setCredentials(new&nbsp;AuthScope("192.168.2.129",&nbsp;55672),</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;UsernamePasswordCredentials("guest",&nbsp;"guest"));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;HttpResponse&nbsp;response&nbsp;=&nbsp;httpclient.execute(httpput);</DIV></DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Could anyone give me some example how to use HTTP API? Thanks.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Johnson</DIV>
<HR style="WIDTH: 210px; HEIGHT: 1px" align=left color=#b5c4df SIZE=1>

<DIV><SPAN>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US>Best regards,<o:p 
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"></o:p></SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US><FONT style="BACKGROUND-COLOR: #ffff00" 
color=#000000></FONT></SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US>Johnson 刘峰</SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US>MOBILE:13776621689&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<o:p 
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"></o:p></SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US>TEL: 025-83191712</SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US>FAX: 025-58783331<o:p 
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"></o:p></SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt">地址:</SPAN><SPAN 
style="FONT-SIZE: 12pt"> </SPAN><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt">南京市雨花区软件大道</SPAN><SPAN 
style="FONT-SIZE: 12pt" lang=EN-US>48</SPAN><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt">号苏豪国际广场</SPAN><SPAN 
style="FONT-SIZE: 12pt" lang=EN-US>A</SPAN><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt">幢一楼</SPAN><SPAN style="FONT-SIZE: 12pt" 
lang=EN-US>A</SPAN><SPAN style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt">区</SPAN><SPAN 
style="FONT-SIZE: 12pt" lang=EN-US><o:p 
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"></o:p></SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt">邮编:</SPAN><SPAN style="FONT-SIZE: 12pt" 
lang=EN-US> 210012</SPAN><SPAN style="FONT-FAMILY: 宋体; FONT-SIZE: 12pt" 
lang=EN-US><o:p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"></o:p></SPAN></P>
<P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" class=MsoNormal><SPAN 
style="FONT-SIZE: 12pt" lang=EN-US><IMG id=图片_x0020_1 alt=logo00 
src="cid:_Foxmail.0@068F4977-EB05-4117-92BC-875EAC414F50" width=60 
height=25></SPAN><SPAN 
style="FONT-FAMILY: 'Baskerville Old Face','serif'; FONT-SIZE: 12pt" 
lang=EN-US>&nbsp;Information System Co. Ltd.<o:p 
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"></o:p></SPAN></P>
<DIV>
<DIV></DIV></DIV></SPAN></DIV></BODY></HTML>