bladelogic

BladeLogic offers a number of ways to connect via an API. Probably their most widely used method is to offer a Command Line Interface (CLI) to perform a number of actions.

BladeLogic also offers a SOAP web service interface that allows folks who are familiar with the CLI to issue those same commands via SOAP. This is called their BladeLogic CLI Tunnel Service.

Before we get into the code I wrote, we need to discuss the SOAP API.

BladeLogic Login Service

In order to use the SOAP API, you must first authenticate using their Login Service. The response to this call will return a token that you must use in your subsequent calls into the API.

Here are the ServiceNow SOAP settings I used for Authentication:

SOAPMessage: BSALoginService
WSDL:

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
 xmlns:loginServiceNamespace="http://bladelogic.com/webservices/skeleton/login"
 xmlns:bladelogicNamespace="http://bladelogic.com/2009/11/30"
 xmlns:frameworkNamespace="http://bladelogic.com/webservices/framework/xsd"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 targetNamespace="http://bladelogic.com/2009/11/30">
  <wsdl:documentation>
  loginServiceNamspace: The namespace for the loginService, which contains login-specific elements.
  bladelogicNamespace: The namespace that contains messages, bindings and SoapActions.
  frameworkNamspace: The namespace for elements used by multiple services, such as generic exceptions.
  wsdl: The WSDL namespace.
  soap: The SOAP namespace.
  xs: The XMLSchema namespace.
  </wsdl:documentation>
  <wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/skeleton/login" >
      <xs:import namespace="http://bladelogic.com/webservices/framework/xsd"/>
            <wsdl:documentation>
            SessionCredentialExpiredException is thrown when a request is made by a user whose session has expired.
            In this case, the user should log in again.            
            </wsdl:documentation>
      <xs:element name="SessionCredentialExpiredException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="SessionCredentialExpiredException" nillable="true" type="frameworkNamespace:SessionCredentialExpiredException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            SessionRejectedException is thrown when a user cannot be authenticated based on the supplied credentials.
            </wsdl:documentation>
      <xs:element name="SessionRejectedException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="SessionRejectedException" nillable="true" type="frameworkNamespace:SessionRejectedException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            The arguments for the loginUsingSessionCredential operation
            </wsdl:documentation>
      <xs:element name="loginUsingSessionCredential">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="ws_sessionCredential" nillable="true" type="frameworkNamespace:WS_SSOSessionCredential"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            The response to a loginUsingSessionCredential request
            </wsdl:documentation>
      <xs:element name="loginUsingSessionCredentialResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="frameworkNamespace:WS_SSOSessionCredential"/>
            <xs:element minOccurs="0" name="returnSessionId" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            The arguments for the loginUsingUserCredential operation
            </wsdl:documentation>
      <xs:element name="loginUsingUserCredential">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="userName" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="authenticationType" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            The response to a loginUsingUserCredential request
            </wsdl:documentation>
      <xs:element name="loginUsingUserCredentialResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="frameworkNamespace:WS_SSOSessionCredential"/>
            <xs:element minOccurs="0" name="returnSessionId" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/framework/xsd">
      <xs:import namespace="http://bladelogic.com/webservices/skeleton/login"/>
      <xs:complexType name="Exception">
        <xs:sequence>
          <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="BaseException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:Exception">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:complexType name="BlException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:BaseException">
            <xs:sequence>
              <xs:element minOccurs="0" name="localizedMessage" nillable="true" type="xs:string"/>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:complexType name="WS_SSOSessionCredential">
        <xs:sequence>
          <xs:element minOccurs="0" name="authType" nillable="true" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="authorizedRoles" nillable="true" type="frameworkNamespace:WSRoleId"/>
          <xs:element minOccurs="0" name="clientAddress" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="expirationTime" nillable="true" type="xs:dateTime"/>
          <xs:element minOccurs="0" name="maximumLifeTime" nillable="true" type="xs:dateTime"/>
          <xs:element minOccurs="0" name="rolePreference" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="serviceTicketString" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="serviceUrl" nillable="true" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="serviceUrls" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="site" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="updateSRPPasswordOnly" type="xs:boolean"/>
          <xs:element minOccurs="0" name="userName" nillable="true" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="webServicesUrls" nillable="true" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="WSRoleId">
        <xs:sequence>
          <xs:element minOccurs="0" name="id" nillable="true" type="xs:int"/>
          <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="roleId" type="xs:int"/>
          <xs:element minOccurs="0" name="roleName" nillable="true" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
            <wsdl:documentation>
            The base exception for login-related exceptions
            </wsdl:documentation>
      <xs:complexType name="SessionLoginException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:BlException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <wsdl:documentation>
            SessionCredentialExpiredException is thrown when a request is made by a user whose session has expired.
            In this case, the user should log in again.            
            </wsdl:documentation>
      <xs:complexType name="SessionCredentialExpiredException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:SessionLoginException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
            <wsdl:documentation>
            SessionRejectedException is thrown when a user cannot be authenticated based on the supplied credentials.
            </wsdl:documentation>
      <xs:complexType name="SessionRejectedException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:SessionLoginException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
            <xs:element name="transactionId" type="xs:string"/>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="loginUsingUserCredentialResponse">
    <wsdl:part name="parameters" element="loginServiceNamespace:loginUsingUserCredentialResponse"/>
  </wsdl:message>
  <wsdl:message name="SessionRejectedException">
    <wsdl:part name="parameters" element="loginServiceNamespace:SessionRejectedException"/>
  </wsdl:message>
  <wsdl:message name="transactionId">
    <wsdl:part name="parameters1" element="frameworkNamespace:transactionId"/>
  </wsdl:message>
  <wsdl:message name="loginUsingUserCredentialRequest">
    <wsdl:part name="parameters" element="loginServiceNamespace:loginUsingUserCredential"/>
  </wsdl:message>
  <wsdl:message name="loginUsingSessionCredentialRequest">
    <wsdl:part name="parameters" element="loginServiceNamespace:loginUsingSessionCredential"/>
  </wsdl:message>
  <wsdl:message name="loginUsingSessionCredentialResponse">
    <wsdl:part name="parameters" element="loginServiceNamespace:loginUsingSessionCredentialResponse"/>
  </wsdl:message>
  <wsdl:message name="SessionCredentialExpiredException">
    <wsdl:part name="parameters" element="loginServiceNamespace:SessionCredentialExpiredException"/>
  </wsdl:message>
  <wsdl:portType name="LoginServicePortType">
    <wsdl:documentation>
        The loginUsingSessionCredential operation allows users to log in using a previously acquired session credential.
        </wsdl:documentation>
    <wsdl:operation name="loginUsingSessionCredential">
      <wsdl:input message="bladelogicNamespace:loginUsingSessionCredentialRequest"/>
      <wsdl:output message="bladelogicNamespace:loginUsingSessionCredentialResponse"/>
      <wsdl:fault name="SessionRejectedException" message="bladelogicNamespace:SessionRejectedException"/>
      <wsdl:fault name="SessionCredentialExpiredException" message="bladelogicNamespace:SessionCredentialExpiredException"/>
    </wsdl:operation>
    <wsdl:documentation>
        The loginUsingUserCredential operation allows users to log in using user credentials.
        </wsdl:documentation>
    <wsdl:operation name="loginUsingUserCredential">
      <wsdl:input message="bladelogicNamespace:loginUsingUserCredentialRequest"/>
      <wsdl:output message="bladelogicNamespace:loginUsingUserCredentialResponse"/>
      <wsdl:fault name="SessionRejectedException" message="bladelogicNamespace:SessionRejectedException"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:documentation>
    The Soap 1.1 Binding
    </wsdl:documentation>
  <wsdl:binding name="LoginServiceSoap11Binding" type="bladelogicNamespace:LoginServicePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:documentation>
        The loginUsingSessionCredential operation allows users to log in using a previously acquired session credential.
        </wsdl:documentation>
    <wsdl:operation name="loginUsingSessionCredential">
      <soap:operation soapAction="bladelogicNamespace:loginUsingSessionCredential" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogic"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="SessionRejectedException">
        <soap:fault name="SessionRejectedException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="SessionCredentialExpiredException">
        <soap:fault name="SessionCredentialExpiredException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
    <wsdl:documentation>
        The loginUsingUserCredential operation allows users to log in using user credentials.
        </wsdl:documentation>
    <wsdl:operation name="loginUsingUserCredential">
      <soap:operation soapAction="bladelogicNamespace:loginUsingUserCredential" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogic"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="SessionRejectedException">
        <soap:fault name="SessionRejectedException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:documentation>
  The LoginService Web Service
    </wsdl:documentation>
  <wsdl:service name="LoginService">
    <wsdl:documentation>
        The Soap 1.1 endpoint for the LoginService
        </wsdl:documentation>
    <wsdl:port name="LoginServiceHttpSoap11Endpoint" binding="bladelogicNamespace:LoginServiceSoap11Binding">
      <soap:address location="https://localhost:9843/services/LoginService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

SOAPFunction: loginUsingUserCredential
SoapAction: bladelogicNamespace:loginUsingUserCredential
SOAP Endpoint: https://YOUR_SERVER:9843/services/LoginService
Envelope:

1
2
3
4
5
6
7
8
9
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://bladelogic.com/webservices/framework/xsd" xmlns:log="http://bladelogic.com/webservices/skeleton/login">
   <soapenv:Body>
      <log:loginUsingUserCredential>
         <log:userName>${userName}</log:userName>
         <log:password>${password}</log:password>
         <log:authenticationType>${authenticationType}</log:authenticationType>
      </log:loginUsingUserCredential>
   </soapenv:Body>
</soapenv:Envelope>

BladeLogic Assume Role Service

Once you have authenticated, you also have to assume the proper role for the work that you will do. Here are the ServiceNow SOAP settings I used for that:

SOAP Message Record: BSAAssumeRoleService
WSDL:

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
  xmlns:assumeRoleServiceNamespace="http://bladelogic.com/webservices/skeleton/assumerole"
  xmlns:bladelogicNamespace="http://bladelogic.com/2009/11/30"
  xmlns:frameworkNamespace="http://bladelogic.com/webservices/framework/xsd"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://bladelogic.com/2009/11/30">
  <wsdl:documentation>
  assumeRoleServiceNamspace: The namespace for the assumeRoleService, which contains assumeRole-specific elements.
  bladelogicNamespace: The namespace that contains messages, bindings and SoapActions.
  frameworkNamspace: The namespace for elements used by multiple services, such as generic exceptions.
  wsdl: The WSDL namespace.
  soap: The SOAP namespace.
  xs: The XMLSchema namespace.
  </wsdl:documentation>
  <wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/skeleton/assumerole">
      <xs:import namespace="http://bladelogic.com/webservices/framework/xsd"/>
      <wsdl:documentation>
            SessionCredentialExpiredException is thrown when a request is made by a user whose session has expired.
            In this case, the user should log in again.            
            </wsdl:documentation>
      <xs:element name="SessionCredentialExpiredException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="SessionCredentialExpiredException" nillable="true" type="frameworkNamespace:SessionCredentialExpiredException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            SessionRejectedException is thrown when a user cannot be authenticated based on the supplied credentials.
            </wsdl:documentation>
      <xs:element name="SessionRejectedException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="SessionRejectedException" nillable="true" type="frameworkNamespace:SessionRejectedException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            The arguments for the assumeRole operation
            </wsdl:documentation>
      <xs:element name="assumeRole">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="roleName" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
            <wsdl:documentation>
            The response to an assumeRole request
            </wsdl:documentation>
      <xs:element name="assumeRoleResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/framework/xsd">
      <xs:complexType name="Exception">
        <xs:sequence>
          <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="BaseException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:Exception">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:complexType name="BlException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:BaseException">
            <xs:sequence>
              <xs:element minOccurs="0" name="localizedMessage" nillable="true" type="xs:string"/>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
            <wsdl:documentation>
            The base exception for login-related exceptions
            </wsdl:documentation>
      <xs:complexType name="SessionLoginException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:BlException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <wsdl:documentation>
            SessionCredentialExpiredException is thrown when a request is made by a user whose session has expired.
            In this case, the user should log in again.            
            </wsdl:documentation>
      <xs:complexType name="SessionCredentialExpiredException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:SessionLoginException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
            <wsdl:documentation>
            SessionRejectedException is thrown when a user cannot be authenticated based on the supplied credentials.
            </wsdl:documentation>
      <xs:complexType name="SessionRejectedException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:SessionLoginException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:element name="sessionId" type="xs:string"/>
      <xs:element name="transactionId" type="xs:string"/>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="SessionRejectedException">
    <wsdl:part name="parameters" element="assumeRoleServiceNamespace:SessionRejectedException"/>
  </wsdl:message>
  <wsdl:message name="sessionId">
    <wsdl:part name="parameters" element="frameworkNamespace:sessionId"/>
  </wsdl:message>
  <wsdl:message name="transactionId">
    <wsdl:part name="parameters1" element="frameworkNamespace:transactionId"/>
  </wsdl:message>
  <wsdl:message name="assumeRoleRequest">
    <wsdl:part name="parameters" element="assumeRoleServiceNamespace:assumeRole"/>
  </wsdl:message>
  <wsdl:message name="assumeRoleResponse">
    <wsdl:part name="parameters" element="assumeRoleServiceNamespace:assumeRoleResponse"/>
  </wsdl:message>
  <wsdl:message name="SessionCredentialExpiredException">
    <wsdl:part name="parameters" element="assumeRoleServiceNamespace:SessionCredentialExpiredException"/>
  </wsdl:message>
  <wsdl:portType name="AssumeRoleServicePortType">
    <wsdl:documentation>
        The assumeRole operation allows users to assume a role after logging in.
        </wsdl:documentation>
    <wsdl:operation name="assumeRole">
      <wsdl:input message="bladelogicNamespace:assumeRoleRequest"/>
      <wsdl:output message="bladelogicNamespace:assumeRoleResponse"/>
      <wsdl:fault name="SessionRejectedException" message="bladelogicNamespace:SessionRejectedException"/>
      <wsdl:fault name="SessionCredentialExpiredException" message="bladelogicNamespace:SessionCredentialExpiredException"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:documentation>
    The Soap 1.1 Binding
    </wsdl:documentation>
  <wsdl:binding name="AssumeRoleServiceSoap11Binding" type="bladelogicNamespace:AssumeRoleServicePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:documentation>
        The assumeRole operation allows users to assume a role after logging in.
        </wsdl:documentation>
    <wsdl:operation name="assumeRole">
      <soap:operation soapAction="bladelogicNamespace:assumeRole" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:sessionId" part="parameters" use="literal" namespace="bladelogic"/>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogic"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="SessionRejectedException">
        <soap:fault name="SessionRejectedException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="SessionCredentialExpiredException">
        <soap:fault name="SessionCredentialExpiredException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:documentation>
  The AssumeRoleService Web Service
    </wsdl:documentation>
  <wsdl:service name="AssumeRoleService">
    <wsdl:documentation>
        The Soap 1.1 endpoint for the AssumeRoleService
        </wsdl:documentation>
    <wsdl:port name="AssumeRoleServiceHttpSoap11Endpoint" binding="bladelogicNamespace:AssumeRoleServiceSoap11Binding">
      <soap:address location="https://localhost:9843/services/AssumeRoleService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

SOAP Message Function: assumeRole
SOAP Action: bladelogicNamespace:assumeRole
SOAP Endpoint: https://YOUR_SERVER:9843/services/AssumeRoleService
Envelope:

1
2
3
4
5
6
7
8
9
10
11
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://bladelogic.com/webservices/framework/xsd" xmlns:ass="http://bladelogic.com/webservices/skeleton/assumerole">
   <soapenv:Header>
      <xsd:sessionId>${sessionID}</xsd:sessionId>
   </soapenv:Header>
   <soapenv:Body>
      <ass:assumeRole>
         <!--Optional:-->
         <ass:roleName>${roleName}</ass:roleName>
      </ass:assumeRole>
   </soapenv:Body>
</soapenv:Envelope>

BladeLogic CLI Tunnel Service

Now for the magic. This service is the one you use to run CLI type commands against the BladeLogic server.

SOAP Message Record: BSACLITunnelService
WSDL:

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:clitunnelServiceNamespace="http://bladelogic.com/webservices/skeleton/clitunnel"
  xmlns:clitunnelModelNamespace="http://bladelogic.com/webservices/model/clitunnel/xsd"
  xmlns:cliFactoryNamespace="http://bladelogic.com/webservices/cli/factory/xsd"
  xmlns:appRemoteNamespace="http://bladelogic.com/webservices/app/remote/xsd"
  xmlns:mfwUtilNamespace="http://bladelogic.com/webservices/mfw/util/xsd"
  xmlns:bladelogicNamespace="http://bladelogic.com/2009/11/30"
  xmlns:frameworkNamespace="http://bladelogic.com/webservices/framework/xsd"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://bladelogic.com/2009/11/30">
  <wsdl:documentation>
  clitunnelServiceNamespace: The namespace for the clitunnelService, which contains cliTunnel-specific elements.
  clitunnelModelNamespace: The namespace for cliTunnelService model objects, such as Result (the command result object).
  appRemoteNamespace: The namespace for remote application exceptions, such as BlRemoteException.
  mfwUtilNamespace: The namespace for model framework exceptions.
  bladelogicNamespace: The namespace that contains messages, bindings and SoapActions.
  frameworkNamespace: The namespace for elements used by multiple services, such as generic exceptions.
  wsdl: The WSDL namespace.
  soap: The SOAP namespace.
  xs: The XMLSchema namespace.
  </wsdl:documentation>
  <wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/skeleton/clitunnel">
      <xs:import namespace="http://bladelogic.com/webservices/app/remote/xsd"/>
      <xs:import namespace="http://bladelogic.com/webservices/cli/factory/xsd"/>
      <xs:import namespace="http://bladelogic.com/webservices/model/clitunnel/xsd"/>
      <xs:element name="BlRemoteException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="BlRemoteException" nillable="true" type="appRemoteNamespace:BlRemoteException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            CommandLoadException is thrown when a CLI command cannot be loaded by the CLI Engine.            
            </wsdl:documentation>
      <xs:element name="CommandLoadException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="CommandLoadException" nillable="true" type="cliFactoryNamespace:CommandLoadException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            CommandLoadException is thrown when the specified CLI command cannot be found.            
            </wsdl:documentation>
      <xs:element name="CommandNotFoundException">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="CommandNotFoundException" nillable="true" type="cliFactoryNamespace:CommandNotFoundException"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The arguments for the executeCommandByParamList operation.            
            </wsdl:documentation>
      <xs:element name="executeCommandByParamList">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="nameSpace" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="commandName" nillable="true" type="xs:string"/>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="commandArguments" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The response to a executeCommandByParamList request.        
            </wsdl:documentation>
      <xs:element name="executeCommandByParamListResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="clitunnelModelNamespace:Result"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The arguments for the executeCommandByParamListAndAttachment operation.            
            </wsdl:documentation>
      <xs:element name="executeCommandByParamListAndAttachment">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="nameSpace" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="commandName" nillable="true" type="xs:string"/>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="commandArguments" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="dh" nillable="true" type="xs:base64Binary"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The response to a executeCommandByParamListAndAttachment request.        
            </wsdl:documentation>
      <xs:element name="executeCommandByParamListAndAttachmentResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="clitunnelModelNamespace:Result"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The arguments for the executeCommandByParamString operation.            
            </wsdl:documentation>
      <xs:element name="executeCommandByParamString">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="nameSpace" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="commandName" nillable="true" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The response to a executeCommandByParamString request.        
            </wsdl:documentation>
      <xs:element name="executeCommandByParamStringResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="clitunnelModelNamespace:Result"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The arguments for the executeCommandUsingAttachments operation.            
            </wsdl:documentation>
      <xs:element name="executeCommandUsingAttachments">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="nameSpace" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="commandName" nillable="true" type="xs:string"/>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="commandArguments" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="payload" nillable="true" type="clitunnelModelNamespace:ClientPayLoad"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <wsdl:documentation>
            The response to a executeCommandUsingAttachments request.        
            </wsdl:documentation>
      <xs:element name="executeCommandUsingAttachmentsResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="return" nillable="true" type="clitunnelModelNamespace:Result"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/model/clitunnel/xsd">
      <wsdl:documentation>
            The result returned by the executeCommand operations.            
            </wsdl:documentation>
      <xs:complexType name="Result">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="attachment" nillable="true" type="xs:base64Binary"/>
          <xs:element minOccurs="0" name="classInstance" type="xs:boolean"/>
          <xs:element minOccurs="0" name="comments" nillable="true" type="xs:string"/>
          <xs:element minOccurs="0" name="error" nillable="true" type="xs:anyType"/>
          <xs:element minOccurs="0" name="executionTime" type="xs:long"/>
          <xs:element minOccurs="0" name="list" type="xs:boolean"/>
          <xs:element minOccurs="0" name="memoryUsed" type="xs:long"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="realInputArguments" nillable="true" type="xs:anyType"/>
          <xs:element minOccurs="0" name="returnValue" nillable="true" type="xs:anyType"/>
          <xs:element minOccurs="0" name="returnValues" nillable="true" type="xs:anyType"/>
          <xs:element minOccurs="0" name="success" type="xs:boolean"/>
        </xs:sequence>
      </xs:complexType>    
      <wsdl:documentation>
            ClientPayload is used for attachment support.            
            </wsdl:documentation>
      <xs:complexType name="ClientPayLoad">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="argumentNameArray" nillable="true" type="xs:string"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="dataHandlerArray" nillable="true" type="xs:base64Binary"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="fileNameArray" nillable="true" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/mfw/util/xsd">
      <xs:import namespace="http://bladelogic.com/webservices/framework/xsd"/>
      <xs:complexType name="BaseException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:Exception">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:complexType name="BlException">
        <xs:complexContent>
          <xs:extension base="mfwUtilNamespace:BaseException">
            <xs:sequence>
              <xs:element minOccurs="0" name="localizedMessage" nillable="true" type="xs:string"/>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/cli/factory/xsd">
    <xs:import namespace="http://bladelogic.com/webservices/framework/xsd"/> 
      <wsdl:documentation>
            CommandLoadException is thrown when a CLI command cannot be loaded by the CLI Engine.            
            </wsdl:documentation>
      <xs:complexType name="CommandLoadException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:Exception">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <wsdl:documentation>
            CommandLoadException is thrown when the specified CLI command cannot be found.            
            </wsdl:documentation>
      <xs:complexType name="CommandNotFoundException">
        <xs:complexContent>
          <xs:extension base="frameworkNamespace:Exception">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/app/remote/xsd">
    <xs:import namespace="http://bladelogic.com/webservices/mfw/util/xsd"/>
      <xs:complexType name="BlRemoteException">
        <xs:complexContent>
          <xs:extension base="mfwUtilNamespace:BlException">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" targetNamespace="http://bladelogic.com/webservices/framework/xsd">
      <xs:complexType name="Exception">
        <xs:sequence>
          <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="sessionId" type="xs:string"/>
      <xs:element name="transactionId" type="xs:string"/>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="executeCommandByParamStringRequest">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandByParamString"/>
  </wsdl:message>
  <wsdl:message name="CommandLoadException">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:CommandLoadException"/>
  </wsdl:message>
  <wsdl:message name="sessionId">
    <wsdl:part name="parameters" element="frameworkNamespace:sessionId"/>
  </wsdl:message>
  <wsdl:message name="transactionId">
    <wsdl:part name="parameters1" element="frameworkNamespace:transactionId"/>
  </wsdl:message>
  <wsdl:message name="CommandNotFoundException">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:CommandNotFoundException"/>
  </wsdl:message>
  <wsdl:message name="BlRemoteException">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:BlRemoteException"/>
  </wsdl:message>
  <wsdl:message name="executeCommandByParamStringResponse">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandByParamStringResponse"/>
  </wsdl:message>
  <wsdl:message name="executeCommandByParamListResponse">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandByParamListResponse"/>
  </wsdl:message>
  <wsdl:message name="executeCommandByParamListAndAttachmentRequest">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandByParamListAndAttachment"/>
  </wsdl:message>
  <wsdl:message name="executeCommandByParamListAndAttachmentResponse">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandByParamListAndAttachmentResponse"/>
  </wsdl:message>
  <wsdl:message name="executeCommandUsingAttachmentsResponse">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandUsingAttachmentsResponse"/>
  </wsdl:message>
  <wsdl:message name="executeCommandUsingAttachmentsRequest">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandUsingAttachments"/>
  </wsdl:message>
  <wsdl:message name="executeCommandByParamListRequest">
    <wsdl:part name="parameters" element="clitunnelServiceNamespace:executeCommandByParamList"/>
  </wsdl:message>
  <wsdl:portType name="CLITunnelServicePortType">
    <wsdl:documentation>
        The executeCommandByParamList operation allows users execute a CLI command with arguments
        </wsdl:documentation>
    <wsdl:operation name="executeCommandByParamList">
      <wsdl:input message="bladelogicNamespace:executeCommandByParamListRequest"/>
      <wsdl:output message="bladelogicNamespace:executeCommandByParamListResponse"/>
      <wsdl:fault name="BlRemoteException" message="bladelogicNamespace:BlRemoteException"/>
      <wsdl:fault name="CommandNotFoundException" message="bladelogicNamespace:CommandNotFoundException"/>
      <wsdl:fault name="CommandLoadException" message="bladelogicNamespace:CommandLoadException"/>
    </wsdl:operation>
    <wsdl:documentation>
        The executeCommandByParamString operation allows users execute a CLI command without arguments
        </wsdl:documentation>
    <wsdl:operation name="executeCommandByParamString">
      <wsdl:input message="bladelogicNamespace:executeCommandByParamStringRequest"/>
      <wsdl:output message="bladelogicNamespace:executeCommandByParamStringResponse"/>
      <wsdl:fault name="BlRemoteException" message="bladelogicNamespace:BlRemoteException"/>
      <wsdl:fault name="CommandNotFoundException" message="bladelogicNamespace:CommandNotFoundException"/>
      <wsdl:fault name="CommandLoadException" message="bladelogicNamespace:CommandLoadException"/>
    </wsdl:operation>
    <wsdl:documentation>
        The executeCommandByParamListAndAttachment operation allows users execute a CLI command with arguments and attachments
        </wsdl:documentation>
    <wsdl:operation name="executeCommandByParamListAndAttachment">
      <wsdl:input message="bladelogicNamespace:executeCommandByParamListAndAttachmentRequest"/>
      <wsdl:output message="bladelogicNamespace:executeCommandByParamListAndAttachmentResponse"/>
      <wsdl:fault name="BlRemoteException" message="bladelogicNamespace:BlRemoteException"/>
      <wsdl:fault name="CommandNotFoundException" message="bladelogicNamespace:CommandNotFoundException"/>
      <wsdl:fault name="CommandLoadException" message="bladelogicNamespace:CommandLoadException"/>
    </wsdl:operation>
    <wsdl:documentation>
        The executeCommandUsingAttachments operation allows users execute a CLI command without arguments and
        with attachements
        </wsdl:documentation>
    <wsdl:operation name="executeCommandUsingAttachments">
      <wsdl:input message="bladelogicNamespace:executeCommandUsingAttachmentsRequest"/>
      <wsdl:output message="bladelogicNamespace:executeCommandUsingAttachmentsResponse"/>
      <wsdl:fault name="BlRemoteException" message="bladelogicNamespace:BlRemoteException"/>
      <wsdl:fault name="CommandNotFoundException" message="bladelogicNamespace:CommandNotFoundException"/>
      <wsdl:fault name="CommandLoadException" message="bladelogicNamespace:CommandLoadException"/>
    </wsdl:operation>
  </wsdl:portType> 
  <wsdl:documentation>
    The Soap 1.1 Binding
    </wsdl:documentation>
  <wsdl:binding name="CLITunnelServiceSoap11Binding" type="bladelogicNamespace:CLITunnelServicePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>  
    <wsdl:documentation>
        The executeCommandByParamList operation allows users execute a CLI command with arguments
        </wsdl:documentation>
    <wsdl:operation name="executeCommandByParamList">
      <soap:operation soapAction="bladelogicNamespace:executeCommandByParamList" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:sessionId" part="parameters" use="literal" namespace="bladelogic"/>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogic"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="BlRemoteException">
        <soap:fault name="BlRemoteException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandNotFoundException">
        <soap:fault name="CommandNotFoundException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandLoadException">
        <soap:fault name="CommandLoadException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
    <wsdl:documentation>
        The executeCommandByParamString operation allows users execute a CLI command without arguments
        </wsdl:documentation>
    <wsdl:operation name="executeCommandByParamString">
      <soap:operation soapAction="bladelogicNamespace:executeCommandByParamString" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:sessionId" part="parameters" use="literal" namespace="bladelogicNamespace"/>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogicNamespace"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="BlRemoteException">
        <soap:fault name="BlRemoteException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandNotFoundException">
        <soap:fault name="CommandNotFoundException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandLoadException">
        <soap:fault name="CommandLoadException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
    <wsdl:documentation>
        The executeCommandByParamListAndAttachment operation allows users execute a CLI command with arguments and attachments
        </wsdl:documentation>
    <wsdl:operation name="executeCommandByParamListAndAttachment">
      <soap:operation soapAction="bladelogicNamespace:executeCommandByParamListAndAttachment" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:sessionId" part="parameters" use="literal" namespace="bladelogicNamespace"/>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogicNamespace"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="BlRemoteException">
        <soap:fault name="BlRemoteException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandNotFoundException">
        <soap:fault name="CommandNotFoundException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandLoadException">
        <soap:fault name="CommandLoadException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
    <wsdl:documentation>
        The executeCommandUsingAttachments operation allows users execute a CLI command without arguments and
        with attachements
        </wsdl:documentation>
    <wsdl:operation name="executeCommandUsingAttachments">
      <soap:operation soapAction="bladelogicNamespace:executeCommandUsingAttachments" style="document"/>
      <wsdl:input>
        <soap:header message="bladelogicNamespace:sessionId" part="parameters" use="literal" namespace="bladelogicNamespace"/>
        <soap:header message="bladelogicNamespace:transactionId" part="parameters1" use="literal" namespace="bladelogicNamespace"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="BlRemoteException">
        <soap:fault name="BlRemoteException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandNotFoundException">
        <soap:fault name="CommandNotFoundException" use="literal"/>
      </wsdl:fault>
      <wsdl:fault name="CommandLoadException">
        <soap:fault name="CommandLoadException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:documentation>
  The CLITunnelService Web Service
    </wsdl:documentation>
  <wsdl:service name="CLITunnelService">
    <wsdl:documentation>
        The Soap 1.1 endpoint for the CLITunnelService
        </wsdl:documentation>
    <wsdl:port name="CLITunnelServiceHttpSoap11Endpoint" binding="bladelogicNamespace:CLITunnelServiceSoap11Binding">
      <soap:address location="https://localhost:9843/services/CLITunnelService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

SOAP Message Function: executeCommandByParamList
SOAP Action: bladelogicNamespace:executeCommandByParamList
SOAP Endpoint: https://YOUR_SERVER:9843/services/CLITunnelService
Envelope:

1
2
3
4
5
6
7
8
9
10
11
12
13
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://bladelogic.com/webservices/framework/xsd" xmlns:clit="http://bladelogic.com/webservices/skeleton/clitunnel">
   <soapenv:Header>
      <xsd:sessionId>${sessionID}</xsd:sessionId>
   </soapenv:Header>
   <soapenv:Body>
      <clit:executeCommandByParamList>
         <clit:nameSpace>${nameSpace}</clit:nameSpace>
         <clit:commandName>${commandName}</clit:commandName>
         <!--Zero or more repetitions:-->
         ${commandArguments}
      </clit:executeCommandByParamList>
   </soapenv:Body>
</soapenv:Envelope>

Helper Script Include Library

The following helper functions allow you to leverage the SOAP Messages with very little worry about authentication, roles, etc.

Please note that for this example, the username and password are embedded in the code rather than queried as system properties.

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
var BLHelper = Class.create();
BLHelper.prototype = {
   logSource: "BladeLogic-Integration",
   initialize: function() {
      this.logLevel = gs.getProperty("com.snc.integration.bladelogic.loglevel", "3");
   },
   /*
    * Authenticate into Blade Logic and return the sessionID
    *   Please Note: This method is automatically called by methods that perform
    *     actions against blade logic and likely do not need to be called
    *     on its own.
    */

   bsaLogin:function(){
     var s = new SOAPMessage('BSALoginService', 'loginUsingUserCredential');
     s.setParameter('authenticationType', 'SRP');
     s.setParameter('userName', 'USERNAME_GOES_HERE');
     s.setParameter('password', 'PASSWORD_GOES_HERE');
     s.post();
     obj = this.getResponse(s);
     if(obj['soapenv:Body'] && obj['soapenv:Body']['ns2:loginUsingUserCredentialResponse']) {
       var sid = obj['soapenv:Body']['ns2:loginUsingUserCredentialResponse']['ns2:returnSessionId'];
       this.log("LOGIN returns a SID of: " + sid);
       gs.setProperty("com.snc.integration.bladelogic.bsa.sid", sid);
       return sid;
    }
   },
   
   /*
    * Assumes the specified role for the specified sessionID
    *
    * RETURNS
    *   nothing
    *
    *   Please Note: This method is automatically called by methods that perform
    *     actions against blade logic and likely do not need to be called
    *     on its own.
    */

   bsaAssumeRole:function(sessionID, role){
     this.log("Attempt to assume the session "+sessionID+" role to be: " + role);
     var s = new SOAPMessage('BSAAssumeRoleService', 'assumeRole');
     s.setParameter('roleName', role);
     s.setParameter('sessionID', sessionID);
     s.post();
     this.getResponse(s); //Wait for response, to keep subsequent calls in sync
   },
   
   /*
    * Performs Blade Logic authentication and assumes the specified role
    *
    * RETURNS
    * nothing
    */

   bsaLoginAndRole:function(role){
     var sid = this.bsaLogin();
     gs.setProperty("com.snc.integration.bladelogic.bsa.sid", sid);
     this.bsaAssumeRole(sid, role);
     return sid;
   },
   
   /*
    * Executes a Blade Logic Command
    *
    * PARAMETERS
    *   sessionID: valid session ID
    *   namespace: Blade Logic Command Namespace
    *   command:  Blade Logic Command
    *   args: Array of arguments
    *   forceLogin: default is false - force a new sessionID to be created first
    *  
    * RETURNS
    *   Response string, if successful.  Otherwise empty string.
    */

    bsaExecuteCli : function(namespace, command, args, forceLogin) {
      if (!forceLogin || forceLogin == false) {
        this.log("Calling BSA assumeRole -- attempting to reuse a previous SID token");
        forceLogin = false;
      } else {
        this.log("Calling BSA assumeRole -- forcing a login first");
      }
      if (forceLogin) {
        var sid = this.bsaLoginAndRole("BLAdmins");
      } else {
        sid = gs.getProperty("com.snc.integration.bladelogic.bsa.sid", "");
      }
      if (sid != "") {
        var arguments = "";
        for ( var key in args) {
          arguments += "<clit:commandArguments>" + args[key] + "</clit:commandArguments>\n";
        }
        var s = new SOAPMessage('BSACLITunnelService', 'executeCommandByParamList');
        s.setParameter('commandArguments', arguments);
        s.setParameter('sessionID', sid);
        s.setParameter('commandName', command);
        s.setParameter('nameSpace', namespace);
        s.post();
        var obj = this.getResponse(s);
        if(this.logLevel >= 3){
          JSUtil.logObject(obj);
        }
   
        if (obj['soapenv:Body'] && obj['soapenv:Body']['ns6:executeCommandByParamListResponse'] && obj['soapenv:Body']['ns6:executeCommandByParamListResponse']['ns6:return']) {
          var returnObject = obj['soapenv:Body']['ns6:executeCommandByParamListResponse']['ns6:return'];
          if (returnObject['ns5:success']['#text'] == "true") {
            this.log("Logging the Return Value Object");
            return returnObject['ns5:returnValue']['#text'];
          }
        }
      }
   
      if (sid == "" || (forceLogin == false && this.bsaCheckForLoginError(obj))) {
        return this.bsaExecuteCli(namespace, command, args, true);
      }
      return "";
   
    },
   
    bsaCheckForLoginError: function(obj){
      this.log("Checking for a login error...")
      if( obj['soapenv:Body'] && obj['soapenv:Body']['soapenv:Fault'] && obj['soapenv:Body']['soapenv:Fault'].detail){
        var exception = obj['soapenv:Body']['soapenv:Fault'].detail.SessionCredentialExpiredException;
        if( exception ){
          this.log("We experienced a login error with: "+exception['@xsi:type']);
          return true;
        }
      }
      this.log("No login expiration errors detected");
      return false;
    },
       
   getResponse: function (s,xml){
    if(!xml && xml!=false){
     xml = true;
    }
      var k = 1;
      var r = s.getResponse();
      while(r == null) {
         this.log("waiting ... " + k + " seconds");
         r = s.getResponse(1000);
         k++;
         
         if (k > 330) {
            this.log("ERROR: Never got a response from web service call through MID Server", 0);
            break; // service did not respond after 30 tries
         }
      }
    if(xml){
     this.log("Got Response of : " +r);
     this.log("Going to call helper");
     var helper = new XMLHelper(r);
     this.log("Helper: " + helper);
     var obj = helper.toObject();
    } else {
       obj = r;
    }
      this.log("OBJ: " + obj);
      return obj;
     
     
   },

   log:function(msg, level){
      if(!level){ level=3 };
       
      if( level <= this.logLevel ){
         gs.log(msg, this.logSource);
      }
   },
   
   type: 'BLHelper'
}

The Library in Action – Scripting with the library

Here are some coding examples using the library above:

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
dbServers = workflow.scratchpad.DBServerDeployQueue;
if(dbServers){
   
   var a = new BLHelper();
   var packageGroup = "/Enterprise_ProductA";
   var packageName = "prodA-Build";
   var jobGroup = "/productAEnt";
   var jobName = "ProdA-DB-"+workflow.scratchpad.dayandtime;
   var simulate = "true";
   var commit = "true";
   var indirect = "false";
     
   var packageKey = a.bsaExecuteCli("BlPackage", "getDBKeyByGroupAndName", [packageGroup, packageName]);
   gs.log("packageKey: " + packageKey);
   
   var groupID = a.bsaExecuteCli("JobGroup", "groupNameToId", [jobGroup]);
   gs.log("groupID: " + groupID);
   
   var jobKey =  a.bsaExecuteCli("DeployJob", "createDeployJob", [jobName, groupID, packageKey, "10.53.2.170", simulate, commit, indirect]);
   gs.log("jobKey: " + jobKey);
   workflow.scratchpad.DBJobKey = jobKey;
   
   var res = a.bsaExecuteCli("DeployJob", "setOverriddenParameterValue", [jobGroup, jobName, "clientCode", workflow.scratchpad.clientCode]);
   gs.log("Set Override Result: " + res);
   
   res = a.bsaExecuteCli("DeployJob", "setOverriddenParameterValue", [jobGroup, jobName, "dbName", workflow.scratchpad.clientBuildDbName]);
   gs.log("Set Override Result: " + res);

   res = a.bsaExecuteCli("DeployJob", "setOverriddenParameterValue", [jobGroup, jobName, "prodaversion", workflow.scratchpad.clientBuildEtimeversion]);
   gs.log("Set Override Result: " + res);

   res = a.bsaExecuteCli("DeployJob", "setOverriddenParameterValue", [jobGroup, jobName, "instanceName", workflow.scratchpad.clientBuildInstanceName]);
   gs.log("Set Override Result: " + res);
   
   if(workflow.scratchpad.executejobs){
      res = a.bsaExecuteCli("Job", "execute", [jobKey]);
      gs.log("Execute Job: " + res);
   } else {
      gs.log("NO EXECUTION OF JOB SINCE WE ARE IN TEST MODE - SEE SCRATCHPAD: workflow.scratchpad.executejobs");
   }
}