2014-04-07 3 views
0

나는 Sap Mii 웹 서비스를 가지고 있는데, 압축 해제가 설정된 상태에서 SoapUI 4.5에서 충돌했을 때. 나는 The Service로부터 적절한 응답을 받는다. 이제 수액 제 삼자 서비스를 사용하기 위해 Pojo 클래스를 작성하려고합니다. 이 서비스는 압축 형식 인 gzip 압축 형식으로 응답을 보냅니다. 이제 비누 UI가이 서비스에서 응답을 추출 할 수 있지만 자바에서이 작업을 수행하는 방법을 알아낼 수 없습니다. 귀하의 솔루션을 기대합니다. 미리 감사드립니다.Java를 통해 SAP MII Web Service를 사용하는 방법은 무엇입니까?

나는 SAP 서비스를 호출하는 코드를 작성했지만, 내가 얻고있는 응답은 위의 서비스의 WSDL이다. 코드는 다음과 같습니다. -

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"); 

soapUI에 실제로 응답하려면 어떻게해야합니까?

+0

Jax-WS를 살펴보십시오. 따라서 SOAP 웹 서비스를 훨씬 쉽게 사용할 수 있습니다. – Simon

+0

귀하의 suggession 당 Jax-WS를 사용했지만 매개 변수를 가져올 수 있지만 해당 매개 변수에 null 값이 있습니다. – Roy

답변

관련 문제