我想把这个SOAP请求发送到我的Groovy服务,
这是我要肥皂
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fin="http://financial.sekuritas.pt.com/" xmlns:java="java:financialgateway.service.RepostInvestorAccountCIMB">
<soapenv:Header/>
<soapenv:Body>
<fin:getData>
<fin:input>
<java:memberCode>test</java:memberCode>
<java:fileContents>somebase64encodedtext</java:fileContents>
<java:crc32>test</java:crc32>
<java:urlWS>test</java:urlWS>
</fin:input>
</fin:getData>
</soapenv:Body>
</soapenv:Envelope>
但是当我尝试使用soap ui提交请求时,出现此错误
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"http://financial.sekuritas.pt.com/", local:"input"). Expected elements are <{}memberCode>,<{}crc32>,<{}fileContents>,<{}urlWS> </faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
在我创建的groovy服务中,我把它做成这样
package com.pt.sekuritas.financial
import grails.transaction.Transactional
import org.grails.cxf.utils.GrailsCxfEndpoint
import java.text.SimpleDateFormat
import javax.annotation.Resource
import javax.jws.WebMethod
import javax.jws.WebParam
import javax.jws.WebResult
import grails.converters.JSON
import javax.servlet.http.HttpServletRequest
import javax.xml.ws.WebServiceContext
import javax.xml.ws.handler.MessageContext
import com.microsoft.sqlserver.jdbc.SQLServerDataSource
import groovy.sql.Sql
import com.pt.sekuritas.backoffice.Registration
@Transactional
@GrailsCxfEndpoint(address="/ReportInvestorAccountCIMB")
class ReportInvestorAccountCIMBService {
def grailsApplication
def base64Decode(encodedString){
byte[] decoded = encodedString.decodeBase64()
String decode = new String(decoded)
return decode
}
@Resource WebServiceContext context
@WebMethod
@WebResult()
getData(@WebParam(name = 'memberCode') String memberCode,
@WebParam(name = 'fileContents') String fileContents,
@WebParam(name = 'crc32') String crc32,
@WebParam(name = 'urlWS') String urlWS
) {
HttpServletRequest request = (HttpServletRequest)context.getMessageContext().get(MessageContext.SERVLET_REQUEST)
def ip = request.getRemoteAddr()
def port = request.getRemotePort()
def host = request.getRemoteHost()
def dateFormatter = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss')
def dateFormatterRtbo = new SimpleDateFormat('yyyy-MM-dd')
def sTime = new SimpleDateFormat('yyyyMMdd')
def nowDate = new Date()
def currentDate = dateFormatter.format(nowDate)
fileContents = base64Decode(fileContents)
def externalReference="";
def sequenceNumber="";
def accountNumber="";
def currency="";
def txnDate="";
def openBalance="";
def closeBalance="";
def txnAmount="";
def txnType="";
def txnCode="";
def txnDesc="";
def accountDebit="";
def accountCredit="";
def test = new XmlParser().parseText(fileContents)
test.each {
if (it.@name == 'StatLine') {
it.'*'.'*'.each {
if (it.@name == 'CashVal') {
def cashVal = new BigDecimal(it.text())
txnAmount= "$cashVal"
}else if (it.@name == 'TrxType') {
def trxType = (it.text())
txnType="$trxType"
}else if (it.@name == 'DC') {
def dc = (it.text())
txnCode="$dc"
}else if (it.@name == 'Description1') {
def description1 = (it.text())
txnDesc="$description1"
}
}
}
}
def xml = new XmlParser().parseText(fileContents)
xml.each {
if(it.@name == 'ExtRef') {
def a = (it.text())
externalReference="$a"
}else if(it.@name == 'SeqNum') {
def b = new BigDecimal(it.text())
sequenceNumber="$b"
} else if(it.@name == 'AC') {
def c = new BigDecimal(it.text())
accountNumber="$c"
} else if(it.@name == 'CurCod') {
def d = (it.text())
currency="$d"
} else if(it.@name == 'ValDate') {
def e = new BigDecimal(it.text())
txnDate="$e"
} else if(it.@name == 'OpenBal') {
def f = new BigDecimal(it.text())
openBalance="$f"
} else if(it.@name == 'CloseBal') {
def g = new BigDecimal(it.text())
closeBalance="$g"
}
}
println("txnDate? "+txnDate)
log.info ('[ReportInvestorAccountCIMBService][ip:' + ip + '][current date:' + currentDate + '][data[externalReference:' + externalReference + ', sequenceNumber:' + sequenceNumber + ', accountNumber:' + accountNumber + ', currency:' + currency + ', txnDate:' + txnDate + ', txnType:' + ', txnCode:' + txnCode + ', accountDebit:' + accountDebit + ', accountCredit:' + accountCredit + ', txnAmount:' + txnAmount + ', openBalance:' + openBalance + ', closeBalance:' + closeBalance + ', txnDesc:' + txnDesc + ']]')
def status = 1
def processDinamis = 0
def processRtbo = 0
if(txnDate == ''){
log.error ('[ReportInvestorAccountCIMBService][ip:' + ip + '][TxnDate: is null]')
return status = 3
}
def financialConfiguration = FinancialGatewayConfiguration.findByIpAddress(ip)
if(financialConfiguration) {
try
{
def p_txnDate = sTime.parse(txnDate)
def financialInstance = FinancialGatewayNotification.findByExternalReference(externalReference)
if(financialInstance)
{
log.error ('[ReportInvestorAccountCIMBService][is exist externalReference:' + externalReference + ']')
return status = 4
}else {
if(txnCode == 'C'){
accountCredit = accountNumber
}else if(txnCode == 'D'){
accountDebit = accountNumber
}
financialInstance = new FinancialGatewayNotification()
financialInstance.externalReference = externalReference
financialInstance.sequenceNumber = sequenceNumber
financialInstance.accountNumber = accountNumber
financialInstance.currency = currency
financialInstance.txnDate = dateFormatter.format(p_txnDate)
financialInstance.txnType = txnType
financialInstance.txnCode = txnCode
financialInstance.accountDebit = accountDebit
financialInstance.accountCredit = accountCredit
financialInstance.txnAmount = txnAmount
financialInstance.openBalance = openBalance
financialInstance.closeBalance = closeBalance
financialInstance.txnDescription = txnDesc
financialInstance.ipAddress = financialConfiguration.ipAddress
financialInstance.sourceBank = financialConfiguration.sourceBank
if (financialInstance.hasErrors()) {
return status
}
financialInstance.save flush: true, failOnError: true
def currDate = sTime.format(nowDate).toString()
def _txnDate = sTime.format(p_txnDate).toString()
//if(_txnDate == currDate) {
try
{
log.info('[ReportInvestorAccountCIMBService]SQL SERVER: ' + grailsApplication.config.dinamis.gateway.db.url)
def sql = Sql.newInstance( grailsApplication.config.dinamis.gateway.db.url,
grailsApplication.config.dinamis.gateway.db.user,
grailsApplication.config.dinamis.gateway.db.password,
grailsApplication.config.dinamis.gateway.db.driver )
sql.execute('INSERT INTO CIMB_H2H (EXTERNAL_REFERENCE, SEQ_NUMBER, ACCOUNT_NUMBER, CURRENCY, TXN_DATE, TXN_TYPE, TXN_CODE, ACCOUNT_DEBIT, ACCOUNT_CREDIT, TXN_AMOUNT, OPEN_BALANCE, CLOSE_BALANCE, TXN_DESC, INSERT_TIME, MEMBER_CODE, CRC32, URL_WS) VALUES(\'' + externalReference + '\', \'' + sequenceNumber + '\', \'' + accountNumber + '\', \'' + currency + '\', \'' + dateFormatter.format(p_txnDate) + '\', \'' + txnType + '\', \'' + txnCode + '\', \'' + accountDebit + '\', \'' + accountCredit + '\', \'' + txnAmount + '\', \'' + openBalance + '\', \'' + closeBalance + '\', \'' + txnDesc + '\', \'' + currentDate + '\', \'' + memberCode + '\', \'' + crc32 + '\', \'' + urlWS + '\')')
processDinamis = 1
sql.close()
}
catch(Exception exc)
{
log.error ('[ReportInvestorAccountCIMBService][ip:' + ip + '][error: SQL EXECUTE')
processDinamis = 0
exc.printStackTrace()
}
/*
}else {
log.info('[ReportInvestorAccountCIMBService][ip:' + ip + '][current date:' + currentDate + '][data[externalReference:' + externalReference + ', sequenceNumber:' + sequenceNumber + ', accountNumber:' + accountNumber + ', currency:' + currency + ', txnDate:' + txnDate + ', txnType:' + ', txnCode:' + txnCode + ', accountDebit:' + accountDebit + ', accountCredit:' + accountCredit + ', txnAmount:' + txnAmount + ', openBalance:' + openBalance + ', closeBalance:' + closeBalance + ', txnDesc:' + txnDesc + ']]The ' + currDate + ' not match with _txnDate ' + _txnDate)
}*/
financialInstance.processResponse = processDinamis
financialInstance.processDate = currentDate
financialInstance.save flush: true, failOnError: true
// S21 RTBO
if(accountNumber) {
try
{
log.info('[ReportInvestorAccountCIMBService]SQL SERVER: ' + grailsApplication.config.rtbo.gateway.db.url)
def sql = Sql.newInstance( grailsApplication.config.rtbo.gateway.db.url,
grailsApplication.config.rtbo.gateway.db.user,
grailsApplication.config.rtbo.gateway.db.password,
grailsApplication.config.rtbo.gateway.db.driver )
sql.execute('EXEC RtboAddFundinout \'' + dateFormatterRtbo.format(p_txnDate) + '\', \'' + currentDate + '\', \'' + txnDesc + '\', null, \'' + accountNumber + '\', \'' + txnAmount + '\', \'' + openBalance + '\', \'' + txnCode + '\', \'' + txnType + '\', \'' + 'H2H' + '\', \'' + '' + '\', \'' + accountDebit + '\', \'' + accountCredit + '\', \'' + externalReference + '\', \'' + 'Cimb' + '\'')
processRtbo = 1
sql.close()
}
catch(Exception exc)
{
log.error ('[ReportInvestorAccountCIMBService][ip:' + ip + '][error: SQL EXECUTE')
processRtbo = 0
exc.printStackTrace()
}
financialInstance.processResponse = processRtbo
financialInstance.processDate = currentDate
financialInstance.save flush: true, failOnError: true
}else {
log.info ('[ReportInvestorAccountCIMBService][ip:' + ip + ']Empty Account Number')
}
try {
if(txnType == '61' && txnDesc == 'PHINTRACO PHINTRACO' && txnAmount == '50000.0000') {
def c = com.pt.sekuritas.backoffice.Registration.createCriteria()
def d = c.list{
eq('rdn', accountNumber)
eq('rdnBank', 'Cimb')
isNotNull('onlineRegistration')
}
if(d.size() > 0) {
def registrationInstance = d[0]
def cal = Calendar.getInstance()
cal.set(Calendar.YEAR, 2021)
cal.set(Calendar.MONTH, 9)
cal.set(Calendar.DATE, 1)
cal.set(Calendar.HOUR, 0)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
def startDate = cal.time
cal.set(Calendar.YEAR, 2022)
cal.set(Calendar.MONTH, 0)
cal.set(Calendar.DATE, 1)
def endDate = cal.time
log.info('[ReportInvestorAccountCIMBService][txnType:' + txnType + '][txnDesc:' + txnDesc + '][accountNumber:' + accountNumber + '][onlineRegistration.dateCreated:' + registrationInstance.onlineRegistration.dateCreated + '][startDate:' + startDate + '][endDate:' + endDate + ']')
if(registrationInstance.onlineRegistration.dateCreated > startDate && registrationInstance.onlineRegistration.dateCreated < endDate) {
//PROMO DIMODALIN
def accountInstance = registrationInstance.onlineRegistration.account
Long longDepositAmount = Float.parseFloat(txnAmount)
java.text.NumberFormat deFormat = java.text.NumberFormat.getInstance(new java.util.Locale("de", "DE"))
def formattedAmount = deFormat.format(longDepositAmount)
def username = registrationInstance.username
def name = registrationInstance.name
def message = '<h2>Yeay!</h2><br/><b>' + name + '</b> Kamu dapat modal Rp' + formattedAmount + ' dari Phintraco Sekuritas.<br/>Cek saldo RDN kamu sekarang ya.<br/>Segera beli saham pilihan kamu.<br/>Ayo tingkatkan investasi kamu dengan top up saldo RDN kamu dan beli saham lebih banyak lagi.<br/>' +
'Salam Profits<br/><b>#bukarekeningdimodalin</b>'
def pushData = ['channel': 'PTANYWHERE_TRANSACTION_NOTIFICATION',
'type':'cashDeposit',
'subType':'',
'sender':'financialGateway',
'recipient': accountInstance.username,
'priority':'0',
'isHtml':'true',
'sentTime': System.currentTimeMillis(),
'title':'Promo Buka Rekening Dimodalin',
'body':message,
'ticker':message,
'targetIntent':'',
'additionalData1':'',
'additionalData2':'',
'additionalData3':'',
'additionalData4':'',
'additionalData5':'',
]
def fcmMessage = (pushData as JSON).toString()
log.info('[ReportInvestorAccountCIMBService][txnType:' + txnType + '][txnDesc:' + txnDesc + '][accountNumber:' + accountNumber + '][username:' + username + '][name:' + name + '][onlineRegistration.dateCreated:' + registrationInstance.onlineRegistration.dateCreated + '][message:' + message + '][fcmMessage:' + fcmMessage + ']')
com.pt.sekuritas.util.ActiveMQHolder.getInstance().pushNotification(fcmMessage)
}
}
}
}
catch(Exception exc) {
log.error ('[ReportInvestorAccountCIMBService][ip:' + ip + '][error: FAILED PROCESSING NOTIFICATION]')
exc.printStackTrace()
}
return status = 1
}
}
catch(Exception exc)
{
log.error ('[ReportInvestorAccountCIMBService][ip:' + ip + '][error: FAILED INSERT]')
exc.printStackTrace()
return status = 0
}
}else {
log.error('[ReportInvestorAccountCIMBService]not found ip address: ' + ip)
return status = 2
}
}
}
我怎么能用这样肥皂发送请求呢?为了符合上面的soap,我应该从我的groovy服务源代码中修改什么?
任何帮助将不胜感激。
1条答案
按热度按时间pinkon5k1#
在不知道此Web服务的WSDL的情况下,我认为您的请求应该如下所示:
如果您在SoapUI中创建了此请求,则可以通过在SoapUI中验证来检查您的请求。(如果我没记错的话,按Alt+V)