title: error 400 bad request with XEP-0055?
body: <p>I got possible fields from my server:</p>
  
  <pre><code>&lt;iq xmlns="jabber:client" from="vjud.company.com" to="testuser@company.com/iPhone" id="search1" type="result"&gt;&lt;query xmlns="jabber:iq:search"&gt;
  
  &lt;instructions&gt;You need an x:data capable client to search&lt;/instructions&gt;
  &lt;x xmlns="jabber:x:data" type="form"&gt;
  &lt;title&gt;Search users in vjud.company.com&lt;/title&gt;
  &lt;instructions&gt;Fill in the form to search for any matching Jabber User (Add * to the end of field to match substring)
  &lt;/instructions&gt;
  &lt;field type="text-single" label="User" var="user"/&gt;
  &lt;field type="text-single" label="Full Name" var="fn"/&gt;
  &lt;field type="text-single" label="Name" var="first"/&gt;
  &lt;field type="text-single" label="Middle Name" var="middle"/&gt;
  &lt;field type="text-single" label="Family Name" var="last"/&gt;
  &lt;field type="text-single" label="Nickname" var="nick"/&gt;
  &lt;field type="text-single" label="Birthday" var="bday"/&gt;
  &lt;field type="text-single" label="Country" var="ctry"/&gt;
  &lt;field type="text-single" label="City" var="locality"/&gt;
  &lt;field type="text-single" label="Email" var="email"/&gt;
  &lt;field type="text-single" label="Organization Name" var="orgname"/&gt;
  &lt;field type="text-single" label="Organization Unit" var="orgunit"/&gt;
  &lt;/x&gt;
  &lt;/query&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p>Suppose I want to search a user with JID <code>admin@company.com</code></p>
  
  <p>Composed request wil look like this:</p>
  
  <pre><code>XMPPIQ *iq2 = [[XMPPIQ alloc] init];
  [iq2 addAttributeWithName:@"type" stringValue:@"set"];
  [iq2 addAttributeWithName:@"from" stringValue:@"testuser@company.com"];
  [iq2 addAttributeWithName:@"to" stringValue:@"vjud.company.com"];
  [iq2 addAttributeWithName:@"id" stringValue:@"search1"];
  XMPPElement *query2 = [XMPPElement elementWithName:@"query"];
  [query2 setXmlns:@"jabber:iq:search"];
  XMPPElement *user = [XMPPElement elementWithName:@"user"];
  [user setStringValue:@"admin"];
  [iq2 addChild:query2];
  [query addChild:user];
  </code></pre>
  
  <p>The error stanza:</p>
  
  <pre><code>&lt;iq xmlns="jabber:client" from="vjud.company.com" to="testuser@company.com/iPhone" type="error" id="search1"&gt;
  &lt;query xmlns="jabber:iq:search"/&gt;
  &lt;error code="400" type="modify"&gt;
  &lt;bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/&gt;
  &lt;/error&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p>So, basically there are 2 questions:</p>
  
  <ol>
  <li>Why there is no <code>&lt;/query&gt;</code> element in response?</li>
  <li>Is it the actual reason of the error?</li>
  </ol>
  
  <p><strong>-The server's response should look like this-</strong></p>
  
  <p>Big thanks to @legoscia user, in case request was composed right, you will get something like this(notice <code>&lt;item&gt;</code> element):</p>
  
  <pre><code>   &lt;iq xmlns="jabber:client" from="vjud.company.com" to="testuser@company.com/iPhone" id="search1" type="result»&gt;
  
   &lt;query xmlns="jabber:iq:search"&gt;&lt;x xmlns="jabber:x:data" type="result»&gt;
   &lt;title&gt;Search Results for vjud.company.com&lt;/title&gt;
   &lt;reported&gt;
   &lt;field type="text-single" label="Jabber ID" var="jid»/&gt;
   &lt;field type="text-single" label="Full Name" var="fn»/&gt;
   &lt;field type="text-single" label="Name" var="first»/&gt;
   &lt;field type="text-single" label="Middle Name" var="middle»/&gt;
   &lt;field type="text-single" label="Family Name" var="last"/&gt;&lt;field type="text-single" label="Nickname" var="nick»/&gt;
   &lt;field type="text-single" label="Birthday" var="bday»/&gt;
   &lt;field type="text-single" label="Country" var="ctry»/&gt;
   &lt;field type="text-single" label="City" var="locality»/&gt;
   &lt;field type="text-single" label="Email" var="email»/&gt;
   &lt;field type="text-single" label="Organization Name" var="orgname"/&gt;&lt;field type="text-single" label="Organization Unit" var="orgunit»/&gt;
   &lt;/reported&gt;
   &lt;item&gt;
   &lt;field var="jid»&gt;
   &lt;value&gt;admin@company.com&lt;/value&gt;
   &lt;/field&gt;
   &lt;field var="fn"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="last"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="first"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="middle"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="nick"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="bday"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="ctry"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="locality"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="email"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="orgname"&gt;&lt;value/&gt;&lt;/field&gt;
   &lt;field var="orgunit"&gt;&lt;value/&gt;&lt;/field&gt;&lt;/item&gt;
   &lt;/x&gt;
   &lt;/query&gt;
   &lt;/iq&gt;
  </code></pre>
  
  <p>If there is no matches,you will just receive <code>&lt;reported&gt;</code> element with lots of fields. You may want to have look at <a href="https://stackoverflow.com/questions/26800596/xep-0055-with-ios-and-ejabberd">this</a> as well.</p>