[groovy-user] WSlite: How to set wsse:Secutiry in header

325 views
Skip to first unread message

Vinay Samudre

unread,
May 2, 2012, 1:57:48 AM5/2/12
to us...@groovy.codehaus.org
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.0')

import wslite.http.auth.*
import wslite.soap.*

def client = new SOAPClient(
                 'http://smssoa.vu.edu.au/VuSite/VuSiteWSSoapHttpPort')

def response = client.send(
      """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmln
s:vus="http://au/edu/vu/its/as/ws/callista/VuSiteWS.wsdl">
   <soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-op
en.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http:/
/docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsse:UsernameToken wsu:Id="UsernameToken-17">
            <wsse:Username>XXXXXX</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-20
0401-wss-username-token-profile-1.0#PasswordText">XXXXXX</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oas
is-200401-wss-soap-message-security-1.0#Base64Binary">OZfu3MKmLaxMYpF+WGEHFA==</
wsse:Nonce>
            <wsu:Created>2012-05-02T05:18:55.425Z</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <vus:getAllSites/>
   </soapenv:Body>

"""
println response.dump()




Above script works but following doesn't works...

def client = new SOAPClient(
                 'http://smssoa.vu.edu.au/VuSite/VuSiteWSSoapHttpPort')

client.authorization = new HTTPBasicAuthorization("XXXXXX", "XXXXX")
//client.httpClient.sslTrustAllCerts = true


def response = client.send(SOAPAction:'http://au/edu/vu/its/as/ws/callista/VuSit
eWS.wsdl/getAllSites') {
    header( ['ClientCredentials.UserName.UserName' :"XXXXXX", 'ClientCredentials.UserName.Password': "XXXXX" ]) {
    }
    body {
        getAllSites(xmlns:'http://au/edu/vu/its/as/ws/callista/VuSiteWS.wsdl/get
AllSites') {
        }
    }

How to setup wsse:security request heading  in wslite?

cheers,
Vinay


Above script works

jwagenleitner

unread,
May 3, 2012, 10:23:33 PM5/3/12
to us...@groovy.codehaus.org

Vinay Samudre wrote
Hi Vinay,

Unfortunately, there is currently no direct support for WS-Security. The
authentication you can set on the client is HTTP Authentication. For
WS-Security you would have to build it out using the markup builder syntax
in the header element in the closure you pass to the send method (or use a
string as you have working).

John


John


--
View this message in context: http://groovy.329449.n5.nabble.com/WSlite-How-to-set-wsse-Secutiry-in-header-tp5679705p5684750.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Vinay Samudre

unread,
May 3, 2012, 11:24:19 PM5/3/12
to us...@groovy.codehaus.org
Thank you very much for your reply John!

Ok, I will try header element. Though WS-Security support would be good.

Thanks again.
Vinay




From: jwagenleitner <john.wag...@gmail.com>
To: us...@groovy.codehaus.org
Sent: Friday, 4 May 2012 12:23 PM
Subject: [groovy-user] Re: WSlite: How to set wsse:Secutiry in header

Vinay Samudre

unread,
May 4, 2012, 1:05:17 AM5/4/12
to us...@groovy.codehaus.org
Update: Tried following but still getting exception.

Caught: wslite.soap.SOAPFaultException: wsse:InvalidSecurity - Missing <wsse:Security> in SOAP Header
        at wslite.soap.SOAPClient.generateSOAPFaultException(SOAPClient.groovy:116)
        at wslite.soap.SOAPClient.this$2$generateSOAPFaultException(SOAPClient.groovy)
        at wslite.soap.SOAPClient.send(SOAPClient.groovy:59)
        at wslite.soap.SOAPClient.send(SOAPClient.groovy:44)
        at GetAllSitesHeader.run(GetAllSitesHeader.groovy:10)

@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.0')

import wslite.http.auth.*
import wslite.soap.*

def client = new SOAPClient(
                 'http://smssoauat.vu.edu.au/VuSite/VuSiteWSSoapHttpPort')



def response = client.send(SOAPAction:'http://au/edu/vu/its/as/ws/callista/VuSiteWS.wsdl/getAllSites') {
    envelopeAttributes 'xmlns:wsse':    'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd',
                       'xmlns:vus':     'http://au/edu/vu/its/as/ws/callista/VuSiteWS.wsdl',
                       'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/'
    header {
       'wsse.Security'( 'soapenv.mustUnderstand':"1") {
          'wsse.UsernameToken' {
             'wsse.Username' {
                'XXXXXXXX'
             }
             'wsse.Password'(Type:'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText') {
                'XXXXXX'
             }
             'wsse.Nonce'(EncodingType:'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary') {
                'OZfu3MKmLaxMYpF+WGEHFA=='
             }
          }
       }
    }
    body {
        getAllSites(xmlns:'http://au/edu/vu/its/as/ws/callista/VuSiteWS.wsdl/getAllSites') {
        }
    }
}

Thank you,
Vinay


From: Vinay Samudre <vinay_...@yahoo.com>
To: "us...@groovy.codehaus.org" <us...@groovy.codehaus.org>
Sent: Friday, 4 May 2012 1:24 PM
Subject: Re: [groovy-user] Re: WSlite: How to set wsse:Secutiry in header
Reply all
Reply to author
Forward
0 new messages