Groovy WSlite and Consuming a Web Service over SSL...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Groovy WSlite and Consuming a Web Service over SSL...

webmediauk
This post has NOT been accepted by the mailing list yet.
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Reply | Threaded
Open this post in threaded view
|

Re: Groovy WSlite and Consuming a Web Service over SSL...

jwagenleitner
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
Reply | Threaded
Open this post in threaded view
|

Re: Groovy WSlite and Consuming a Web Service over SSL...

webmediauk
Hey John,
Thanks very much for the reply and advice to join the listsrv (I thought I had but obviously not!)

The service I need to connect to requires not only HTTPS, but they specify that I need to provide a username, password and account name.

I've copied this from the API document I have:

"Client Usage and Communication

Clients can be written in any format that supports the SOAP protocol and understands WSDL. This Guide includes examples for a Java Client. Please seethe Sample Java Client topic.

The path to the WSDL document:
https://your.oas.host/oasapi/OaxApi?wsdl

Example: https://openadstream.247realmedia.com/oasapi/OaxApi?wsdl

The encoding style of this WSDL document is rpc/literal.
If you need a document/literal encoding style WSDL document to prime your Microsoft .NET Web Reference, use the following URL: https://your.oas.host/oas/wsdl/oasApi.wsdl
The information provided below is contained in the WSDL document above. However, if your SOAP implementation library does not process WSDL, it requires the following information:

The namespace: “https://api.oas.tfsm.com/”
The service name: “OaxApiService”
The port name: “OaxApiPort”
The operation (method name): “OasXmlRequest”
Additionally, the “OasXmlRequest” method requires four string arguments, in the following order:

Account ID
OAS User ID
OAS User Password
AdXML
Finally, the return type of the “OASXmlRequest” method is also a string inAdXML format (See alsoAdXML RequestandAdXML Response)."

I understand how to send the XML for the AdXML they describe, but I can't find any examples of how to attach the strings they need for "Account ID", "OAS User ID" etc?

Am I being stupid?!

Many Thanks
Barry


jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
Reply | Threaded
Open this post in threaded view
|

Re: Groovy WSlite and Consuming a Web Service over SSL...

jwagenleitner
Hi Barry,

I would recommend using a tool like soapUI.  If you give it the URL to the WSDL it will generate a sample request.

I was able to find this WSDL online, https://openadstream17.247realmedia.com/oasapi/OaxApi?wsdl.  Sample request looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.oas.tfsm.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <api:OasXmlRequest>
         <String_1>?</String_1>
         <String_2>?</String_2>
         <String_3>?</String_3>
         <String_4>?</String_4>
      </api:OasXmlRequest>
   </soapenv:Body>
</soapenv:Envelop

So using groovy-wslite, you would do something like:

def client = new SOAPClient("https://openadstream17.247realmedia.com:443/oasapi/OaxApi")
def response = client.send(SOAPAction: 'OasXmlRequest') {
    body {
        'api:OasXmlRequest'('xmlns:api':'http://api.oas.tfsm.com/') {
            String_1("Account ID")
            String_2("OAS User ID")
            String_3("OAS User Password")
            String_4 {
                AdXML { ...}
            }
        }
}

John

<quote author="webmediauk">
Hey John,
Thanks very much for the reply and advice to join the listsrv (I thought I had but obviously not!)

The service I need to connect to requires not only HTTPS, but they specify that I need to provide a username, password and account name.

I've copied this from the API document I have:

"Client Usage and Communication

Clients can be written in any format that supports the SOAP protocol and understands WSDL. This Guide includes examples for a Java Client. Please seethe Sample Java Client topic.

The path to the WSDL document:
https://your.oas.host/oasapi/OaxApi?wsdl

Example: https://openadstream.247realmedia.com/oasapi/OaxApi?wsdl

The encoding style of this WSDL document is rpc/literal.
If you need a document/literal encoding style WSDL document to prime your Microsoft .NET Web Reference, use the following URL: https://your.oas.host/oas/wsdl/oasApi.wsdl
The information provided below is contained in the WSDL document above. However, if your SOAP implementation library does not process WSDL, it requires the following information:

The namespace: “https://api.oas.tfsm.com/”
The service name: “OaxApiService”
The port name: “OaxApiPort”
The operation (method name): “OasXmlRequest”
Additionally, the “OasXmlRequest” method requires four string arguments, in the following order:

Account ID
OAS User ID
OAS User Password
AdXML
Finally, the return type of the “OASXmlRequest” method is also a string inAdXML format (See alsoAdXML RequestandAdXML Response)."

I understand how to send the XML for the AdXML they describe, but I can't find any examples of how to attach the strings they need for "Account ID", "OAS User ID" etc?

Am I being stupid?!

Many Thanks
Barry


jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John
jwagenleitner wrote
webmediauk wrote
Hi,
I'm a newbie to groovy but have some java experience. My grails application needs to consume a WSDL web service, but it needs to do so over SSL (https). I've managed to get my app to talk to a different web service over http using wslite and was just wondering if this is possible with https?
If so can anyone give me some example code?
Many Thanks
Barry
Hi Barry,

Calling a service over https should just work assuming the server has a valid ssl cert.  If the cert is self-signed or not provided by a root ca that the JDK trusts you have two options, (1) past trustAllSSLCerts:true in the request or (2) set javax.net.ssl.trustStore/javax.net.ssl.trustStorePassword System properties.

Example 1:

    import wslite.soap.*
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction', trustAllSSLCerts:true) {
        ....
    }

Example 2:

    import wslite.soap.*
    System.setProperty("javax.net.ssl.trustStore", "/full-path-to-jks-keystore")
    System.setProperty("javax.net.ssl.trustStorePassword", "secret")
    def client = new SOAPClient("https://...")
    def response = client.send(SOAPAction:'someAction') {
        ....
    }

There are some changes for the upcoming 0.2 release that will allow you to specify a custom trustStore at the client or request level.  However, as of the latest release 0.1 it's still possible to connect to https web services.

Btw, you might want to consider subscribing to the listserv.  Your post was only on Nabble and was never sent to the actual listserv, so the number of views was probably quite limited.

John