我正在使用 Grails 2.2.3。我无法使用 Grails 中的参数调用基于 SOAP 的 JAVA Web 服务。我正在使用wslite。我们能够调用基于 SOAP 的 Web 服务,但是当我们传递参数时,在服务器端总是接收为 NULL。
My Groovy Code snippet is as follows:
package poc.service
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.8.0')
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import wslite.soap.SOAPClient
import wslite.http.HTTPRequest
import wslite.http.HTTPResponse
class LoginService {
static def checkUserData(def _userName12) {
def client = new SOAPClient('http://192.168.14.147:9090/SOAPServiceDemo/authenticate')
def userNameValue = _userName12
def response = client.send(SOAPAction:'\"http://example.service.com/checkUser\"'){
header{
}
body {
checkUser(xmlns:'http://example.service.com/') {
userName12(_userName12)
}
}
}
println "User Name = " + response.checkUserResponse.return
}
static main(args){
def status = checkUserData('123')
println status
}
}
Below is another example which is working fine. It is copied from google.
package poc.service
import wslite.soap.SOAPClient
import wslite.http.HTTPRequest
import wslite.http.HTTPResponse
class MothersDay {
static def checkMotherData(String _userName12) {
def client = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')
def response = client.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMothersDay') {
body {
GetMothersDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
year(_userName12)
}
}
}
println "Result = " + response.GetMothersDayResponse.GetMothersDayResult.toString()
}
static main(args){
def status = checkMotherData("2018")
}
}
Please let me know if you have any idea where I am lacking.
Thanks
Ravi