title: How to consume SAP MII Web Service through Java?
body: <p>I have a Sap Mii Web service that when i hit from SoapUI 4.5 with Decompression Enabled. I get a Proper response from The Service. Now i want to write a Pojo Class to consume the sap MII Service. This service sends the response in Compressed format that is gzip Compression. now the soap ui is able to extract the response from this service but how to do this in java, I am unable to figure out. Looking forward to your solutions. Thanks in advance.</p>
  
  <p>I have written a code that invokes the sap service but the response that i am getting is the wsdl of the above service. Here is the code :-</p>
  
  <pre><code>SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
          SOAPConnection sc = scf.createConnection();
          MessageFactory mf = MessageFactory.newInstance();
          SOAPMessage message = mf.createMessage();
  
          //************** HERE YOU DO THE GZIP********************************
          MimeHeaders hd = message .getMimeHeaders();
          hd.addHeader("Accept-Encoding", "gzip,deflate,sdch");
          /*
          .... some code
          */
          URL url = new URL("http://10.241.108.192:50000/XMII/WSDLGen/Demo/testTrx?wsdl");
          SOAPMessage reply = sc.call(message, url);
          System.out.println("Lets see if i get the reply ==== " + reply.toString());
          // The response is gzip encoded, so decompress the response.
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          reply.writeTo(out);
          byte[] barr = out.toByteArray();
          InputStream gzipStream = new GZIPInputStream(new ByteArrayInputStream(barr));
          Reader decoder = new InputStreamReader(gzipStream, "UTF-8");
          BufferedReader buffered = new BufferedReader(decoder);
          int n = 0;
          char[] cbuf = new char[1024];
          Writer w = new StringWriter();
          while ((n = buffered.read(cbuf)) != -1) {
              w.write(cbuf,0,n);
          }
          // the writer now contains unzipped message.
          System.out.println(w.toString());
          System.out.println("Done");
  </code></pre>
  
  <p>What should i do to get actual response which i am getting in the soapUI?</p>