Showing posts with label ADMIN SERVICE. Show all posts
Showing posts with label ADMIN SERVICE. Show all posts

Tuesday, October 16, 2012

How to invoke Admin Services with SoapUI

It is very very easy to invoke WSO2 Carbon Admin Services with SOAP UI.

Step 1. 
Use the AuthenticationAdmin Service to obtain the session cookie.
You can access the AuthenticationAdmin WSDL of a carbon server with the following url assuming that the server is running with default ports.

http://localhost:9763/services/AuthenticationAdmin?wsdl

SOAP SoapUI to generate the Client for it.
Now invoke the login method. A sample request would be like



<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:aut="http://authentication.services.core.carbon.wso2.org">
   <soap:Header/>
   <soap:Body>
      <aut:login>
         <!--Optional:-->
         <aut:username>admin</aut:username>
         <!--Optional:-->
         <aut:password>admin</aut:password>
         <!--Optional:-->
         <aut:remoteAddress>127.0.0.1</aut:remoteAddress>
      </aut:login>
   </soap:Body>
</soap:Envelope>


In the response message, an HTTP Header will be available with a session cookie.

HTTP/1.1 200 OK

Set-Cookie: JSESSIONID=2671C3A974C0FE67BD9D1DDF665E1DC3; Path=/; Secure; HttpOnly
Content-Type: application/soap+xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 16 Oct 2012 18:48:33 GMT
Server: WSO2 Carbon Server

Step 2.

Now when invoking any other admin service, add the http header COOKIE from soap UI.

COOKIE: JSESSIONID=2671C3A974C0FE67BD9D1DDF665E1DC3
A sample request message would look like 

POST http://localhost:9763/services/ProcessManagementService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:getProcessInfo"
COOKIE: JSESSIONID=2671C3A974C0FE67BD9D1DDF665E1DC3
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:9763
Content-Length: 571

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>local://services/ProcessManagementService</wsa:To>
<wsa:MessageID>urn:uuid:ac59f8ff-de2e-42d1-88f6-2542d54a869c</wsa:MessageID>
<wsa:Action>urn:getProcessInfo</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<ns1:getProcessInfoIn xmlns:ns1="http://wso2.org/bps/management/schema">
<ns1:pid xmlns:s13="http://ode/bpel/unit-test">s13:HelloWorld2-2</ns1:pid>
</ns1:getProcessInfoIn>
</soapenv:Body>
</soapenv:Envelope>