/**
* saves service response to file
*
* @param response
* @throws Exception
*/
private void saveFile(SOAPMessage msg, String filename) throws Exception {
if( msg != null ) {
if(StringUtils.isEmpty(wsresponsefile)) {
wsresponsefile = "testResponse.xml";
}
System.out.println("Saving service response: " + filename);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filename);
msg.writeTo(fos);
}
catch(Exception e) {
e.printStackTrace();
}
finally {
IOUtils.close(fos);
}
}
}
private SOAPMessage createSOAPMsgFromFile(String filename) throws Exception {
if ( ! StringUtils.isEmpty(filename) ) {
System.out.println("Loading request payload: " + filename);
FileInputStream fis = null;
try {
fis = new FileInputStream(filename);
return MessageFactory.newInstance().createMessage(null, fis);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
IOUtils.close(fis);
}
}
return null;
}
public static void main(String[] a) throws Exception {
new SoapClient().testWebService();
}
}
{code}
SOAP request --------------
{code}
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<sc:getPersonRequest xmlns:sc="http://www.t50.com/portable"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.t50.com/portable GetPerson.xsd ">
<person>
<firstName>john</firstName>
<lastName>wang</lastName>
<age>86</age>
</person>
</sc:getPersonRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
{code}
SOAP response --------------
{code}
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getPersonResponse xmlns:ns2="http://www.t50.com/portable">
<person>
<firstName>john</firstName>
<lastName>wang</lastName>
<age>30001</age>
</person>
</ns2:getPersonResponse>
</S:Body>
</S:Envelope>
{code}