Question

I cannot set preemptive authentication in groovyws. (ws provider required preemptive authentication.)

I try to find out in groovyws document but no clue.

import groovyx.net.ws.WSClient

//def proxy = new WSClient("http://202.44.4.97/webservice/pttinfo.asmx?wsdl", this.class.classLoader)
def proxy = new WSClient("http://192.168.3.69/provider/myService", this.class.classLoader)
proxy.setBasicAuthentication('user', 'pass')

proxy.initialize()

below is an error.

Caused by: java.io.IOException: Server returned HTTP response code: 405 for URL: http://192.168.3.69/provider/myService
Was it helpful?

Solution

Have you tried groovy-wslite? It says in the documentation for GroovyWS that:

Due to low availability the project is currently dormant, you might consider groovy-wslite as a replacement module

So afaics, this should get close (I'm assuming you're using SOAP):

import wslite.soap.*
def client = new SOAPClient('http://192.168.3.69/provider/myService')
client.authorization = new HTTPBasicAuthorization( 'user', 'pass' )

There are instructions for getting wslite working with Grails here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top