Hi
I have this code, that retreives me an XML message. How can I convert the result (Type ResultStream) to a String type?
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection conn = scf.createConnection();
// Create message
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
// Object for message parts
SOAPPart sp = msg.getSOAPPart();
StreamSource prepMsg = new StreamSource(
new FileInputStream("D:/SoapRequest/soap.txt"));
sp.setContent(prepMsg);
// Save message
msg.saveChanges();
// View input
System.out.println("\n Soap request:\n");
msg.writeTo(System.out);
System.out.println();
// Send
Authenticator.setDefault(new MyAuthenticator());
String urlval = "http://....";
SOAPMessage rp = conn.call(msg, urlval);
// View the output
System.out.println("\nXML response\n");
// Create transformer
TransformerFactory tff = TransformerFactory.newInstance();
Transformer tf = tff.newTransformer();
// Get reply content
Source sc = rp.getSOAPPart().getContent();
// Set output transformation
StreamResult result = new StreamResult(System.out);
tf.transform(sc, result);
System.out.println();
This works, and I get the soap response printed...however i need a String to save it to a file.
Thank you in advance
I have this code, that retreives me an XML message. How can I convert the result (Type ResultStream) to a String type?
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection conn = scf.createConnection();
// Create message
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
// Object for message parts
SOAPPart sp = msg.getSOAPPart();
StreamSource prepMsg = new StreamSource(
new FileInputStream("D:/SoapRequest/soap.txt"));
sp.setContent(prepMsg);
// Save message
msg.saveChanges();
// View input
System.out.println("\n Soap request:\n");
msg.writeTo(System.out);
System.out.println();
// Send
Authenticator.setDefault(new MyAuthenticator());
String urlval = "http://....";
SOAPMessage rp = conn.call(msg, urlval);
// View the output
System.out.println("\nXML response\n");
// Create transformer
TransformerFactory tff = TransformerFactory.newInstance();
Transformer tf = tff.newTransformer();
// Get reply content
Source sc = rp.getSOAPPart().getContent();
// Set output transformation
StreamResult result = new StreamResult(System.out);
tf.transform(sc, result);
System.out.println();
This works, and I get the soap response printed...however i need a String to save it to a file.
Thank you in advance