1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.actions.monitor;
14
15 import com.eviware.soapui.impl.WsdlInterfaceFactory;
16 import com.eviware.soapui.impl.wsdl.WsdlProject;
17 import com.eviware.soapui.impl.wsdl.panels.monitor.SoapMonitorDesktopPanel;
18 import com.eviware.soapui.impl.wsdl.support.HelpUrls;
19 import com.eviware.soapui.model.iface.Interface;
20 import com.eviware.soapui.model.settings.Settings;
21 import com.eviware.soapui.support.StringUtils;
22 import com.eviware.soapui.support.UISupport;
23 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
24 import com.eviware.soapui.support.types.StringList;
25 import com.eviware.x.form.XFormDialog;
26 import com.eviware.x.form.support.ADialogBuilder;
27 import com.eviware.x.form.support.AField;
28 import com.eviware.x.form.support.AField.AFieldType;
29 import com.eviware.x.form.support.AForm;
30
31 public class SoapMonitorAction extends AbstractSoapUIAction<WsdlProject>
32 {
33 private XFormDialog dialog;
34
35 public SoapMonitorAction()
36 {
37 super("Launch SOAP Monitor", "Launches a SOAP traffic monitor for this project");
38 }
39
40 public void perform(WsdlProject target, Object param)
41 {
42 if (target.getInterfaceCount() == 0)
43 {
44 UISupport.showErrorMessage("Missing interfaces to monitor");
45 return;
46 }
47
48 if (dialog == null)
49 {
50 dialog = ADialogBuilder.buildDialog(LaunchForm.class);
51 }
52
53 Settings settings = target.getSettings();
54
55 StringList endpoints = new StringList();
56 endpoints.add(null);
57
58 for (Interface iface : target.getInterfaceList())
59 {
60 if (iface.getInterfaceType().equals(WsdlInterfaceFactory.WSDL_TYPE))
61 endpoints.addAll(iface.getEndpoints());
62 }
63
64 dialog.setIntValue(LaunchForm.PORT, (int) settings.getLong(LaunchForm.PORT, 8081));
65 dialog.setOptions(LaunchForm.REQUEST_WSS, StringUtils.merge(target.getWssContainer().getIncomingWssNames(),
66 "<none>"));
67 dialog.setOptions(LaunchForm.RESPONSE_WSS, StringUtils.merge(target.getWssContainer().getIncomingWssNames(),
68 "<none>"));
69
70 if (dialog.show())
71 {
72 int listenPort = dialog.getIntValue(LaunchForm.PORT, 8080);
73 settings.setLong(LaunchForm.PORT, listenPort);
74
75 openSoapMonitor(target, listenPort, dialog.getValue(LaunchForm.REQUEST_WSS), dialog
76 .getValue(LaunchForm.RESPONSE_WSS), dialog.getBooleanValue( LaunchForm.SETASPROXY ));
77 }
78 }
79
80 protected void openSoapMonitor(WsdlProject target, int listenPort, String incomingRequestWss,
81 String incomingResponseWss, boolean setAsProxy)
82 {
83 UISupport.showDesktopPanel(new SoapMonitorDesktopPanel(target, listenPort, incomingRequestWss,
84 incomingResponseWss, setAsProxy));
85 }
86
87 @AForm(description = "Specify SOAP Monitor settings", name = "Launch SOAP Monitor", helpUrl = HelpUrls.SOAPMONITOR_HELP_URL )
88 private interface LaunchForm
89 {
90 @AField(description = "The local port to listen on", name = "Port", type = AFieldType.INT)
91 public final static String PORT = "Port";
92
93 @AField(description = "The Incoming WSS configuration to use for processing requests", name = "Incoming Request WSS", type = AFieldType.ENUMERATION)
94 public final static String REQUEST_WSS = "Incoming Request WSS";
95
96 @AField(description = "The Outgoing WSS configuration to use for processing responses", name = "Incoming Response WSS", type = AFieldType.ENUMERATION)
97 public final static String RESPONSE_WSS = "Incoming Response WSS";
98
99 @AField(description = "Set as Global Proxy", name = "Set as Proxy", type = AFieldType.BOOLEAN)
100 public final static String SETASPROXY = "Set as Proxy";
101
102 }
103 }