-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSOAP-GUI.ps1
100 lines (84 loc) · 3.27 KB
/
SOAP-GUI.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
## SOAP test GUI
clear
# Load the Winforms assembly
[reflection.assembly]::LoadWithPartialName( "System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
# Close function
function do_exit
{
$form.close()
}
function Execute-SOAPRequest
(
[Xml] $SOAPRequest,
[String] $URL
)
{
write-host "Sending SOAP Request To Server: $URL"
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction","`"http://www.webserviceX.NET/ChangeMetricWeightUnit`"")
$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Method = "POST"
write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()
$SOAPRequest.Save($requestStream)
$requestStream.Close()
write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()
$responseStream.Close()
write-host "Response Received."
return $ReturnXml
}
# Create form, size, position and border style
$form= New-Object Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size(400,400)
$form.StartPosition = "CenterScreen"
$form.FormBorderStyle = 'Fixed3D'
$form.Text = " A Powershell GUI by Juan Hernandez"
## Create a close button, add text, set location, action and add it to the form
$B_close = New-Object Windows.Forms.Button
$B_close.text = "Close"
$B_close.Location = New-Object Drawing.Point 305,330
$B_close.add_click({do_exit})
$form.controls.add($B_close)
# Create a label with text, size, location and add it to the form
$label = New-Object Windows.Forms.Label
$label.Location = New-Object Drawing.Point 20,20
$label.Size = New-Object Drawing.Point 150,20
$label.text = "Enter endpoint:"
$form.controls.add($label)
##create an input box
$InputTextBox = New-Object System.Windows.Forms.TextBox
$InputTextBox.Location = New-Object System.Drawing.Size(20,40)
$InputTextBox.Size = New-Object System.Drawing.Size(350,20)
$form.Controls.Add($InputTextBox)
# Create a label with text, size, location and add it to the form
$label2 = New-Object Windows.Forms.Label
$label2.Location = New-Object Drawing.Point 20,70
$label2.Size = New-Object Drawing.Point 150,20
$label2.text = "Enter SOAP bericht:"
$form.controls.add($label2)
##create an input box
$InputTextBox2 = New-Object System.Windows.Forms.TextBox
$InputTextBox2.Location = New-Object System.Drawing.Size(20,90)
$InputTextBox2.Size = New-Object System.Drawing.Size(350,200)
$InputTextBox2.Multiline = "true";
$form.Controls.Add($InputTextBox2)
## create a button, tekst, position, action and add it to the form
$B_sub = New-Object Windows.Forms.Button
$B_sub.text = "Submit Test"
$B_sub.Location = New-Object Drawing.Point 20,330
$B_sub.add_click(
{
$soap = [xml] $InputTextBox2.Text;
$url = $InputTextBox.Text;
$ret = Execute-SOAPRequest $soap $url;
$ret | Export-Clixml "c:\tmp\response.xml";
}
)
$form.controls.add($B_sub)
## show the form
$form.ShowDialog()