title: ADWS with Java and tcp
body: <p>I'm trying to create a simple java client to contact Microsoft Active Directory Web Service (to 10.10.41.0). Using Microsoft documentation (here <a href="http://msdn.microsoft.com/en-us/library/dd976885.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd976885.aspx</a>) I develop the follow code:</p>
  
  <pre><code>String str = "&lt;soapenv:Envelope" 
  + " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\""
  + " xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"&gt;"
  + " &lt;soapenv:Header&gt;"
  + " &lt;wsa:Action soapenv:mustUnderstand=\"1\"&gt;http://10.10.41.0:9389/ActiveDirectory/CustomActions/TopologyManagement/GetVersion&lt;/wsa:Action&gt;"
  + " &lt;wsa:MessageID&gt;urn:uuid:680a119e-d421-41f6-8e84-b3d3d8887e49&lt;/wsa:MessageID&gt;"
  + " &lt;wsa:ReplyTo&gt;"
  + " &lt;wsa:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/wsa:Address&gt;"
  + " &lt;/wsa:ReplyTo&gt;"
  + " &lt;wsa:To soapenv:mustUnderstand=\"1\"&gt;net.tcp://10.10.41.0:9389/ActiveDirectoryWebServices/Windows/TopologyManagement&lt;/wsa:To&gt;"
  + " &lt;/soapenv:Header&gt;"
  + " &lt;soapenv:Body&gt;"
  + " &lt;GetVersionRequest xmlns=\"http://10.10.41.0:9389/ActiveDirectory/CustomActions\"&gt;&lt;/GetVersionRequest&gt;"
  + " &lt;/soapenv:Body&gt;" + " &lt;/soapenv:Envelope&gt;";
  ...
  System.out.println(str);
  SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
  SOAPConnection connection = sfc.createConnection();
  InputStream is = new ByteArrayInputStream(str.getBytes());
  SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);
  request.removeAllAttachments();
  
  SOAPPart part = request.getSOAPPart();
  part.detachNode();
  SOAPEnvelope env = part.getEnvelope();
  env.detachNode();
  SOAPBody body = env.getBody();
  body.detachNode();
  SOAPHeader head = env.getHeader();
  head.detachNode();
  
  request.writeTo(System.out);
  
  URL endpoint = new URL("http://10.10.41.0:9389");
  SOAPMessage response = connection.call(request, endpoint);
  System.out.println(response.getContentDescription());
  </code></pre>
  
  <p>The program crash with the following error:</p>
  
  <pre><code>17-dic-2013 10.26.12 com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl createEnvelopeFromSource
  GRAVE: SAAJ0304: InputStream does not represent a valid SOAP 1.1 Message
  javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.1 Message
  at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:75)
  at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:122)
  at TCPClient.main(TCPClient.java:52)
  </code></pre>