Skip to content

Instantly share code, notes, and snippets.

@barancev
Last active September 4, 2021 14:37
Show Gist options
  • Save barancev/6375c1be99155f0121145d6b2bd354d5 to your computer and use it in GitHub Desktop.
Save barancev/6375c1be99155f0121145d6b2bd354d5 to your computer and use it in GitHub Desktop.
package ru.stqa.pft.mantis.appmanager;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
public class AxisLogHandler extends BasicHandler {
private static final long serialVersionUID = 1L;
@Override public void invoke(MessageContext msgContext) {
try {
logMessage(msgContext);
} catch (Exception e) {
e.printStackTrace();
}
}
private void logMessage(MessageContext msgContext) throws Exception{
Message inMsg = msgContext.getRequestMessage();
Message outMsg = msgContext.getResponseMessage();
if(outMsg == null) {
System.out.println("============================= REQUEST ============================================");
inMsg.writeTo(System.out);
System.out.println("");
}
else {
System.out.println("===================================RESPONSE======================================");
outMsg.writeTo(System.out);
}
}
@Override public void onFault(MessageContext msgContext) { super.onFault(msgContext);
try {
logMessage(msgContext);
} catch (Exception e) {
e.printStackTrace();
}
}
}
private MantisConnectPortType getMantisConnect() throws ServiceException, MalformedURLException {
SimpleProvider clientConfig = new SimpleProvider();
AxisLogHandler logHandler = new AxisLogHandler();
SimpleChain reqHandler = new SimpleChain();
SimpleChain respHandler = new SimpleChain();
reqHandler.addHandler(logHandler);
respHandler.addHandler(logHandler);
Handler pivot = new HTTPSender();
Handler transport = new SimpleTargetedChain(reqHandler, pivot, respHandler);
clientConfig.deployTransport(HTTPTransport.DEFAULT_TRANSPORT_NAME, transport);
MantisConnectLocator locator = new MantisConnectLocator();
locator.setEngineConfiguration(clientConfig);
locator.setEngine(new AxisClient(clientConfig));
return locator.getMantisConnectPort(new URL("http://localhost/mantisbt-1.2.20/api/soap/mantisconnect.php"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment