使用带Grails的XML创建SOAP请求

时间:2017-05-05 13:59:52

标签: xml grails soap

我需要构建一个以特定模式发送XML的方法。但我找不到用Grails构建这个的方法。这是我需要构建的XML示例。任何人都可以帮助我吗?

printf

1 个答案:

答案 0 :(得分:0)

类似的东西:

import groovy.xml.StreamingMarkupBuilder
import groovy.xml.XmlUtil

def xmlBuilder = new StreamingMarkupBuilder()
writer = xmlBuilder.bind {
    mkp.declareNamespace( 'soapenv': "http://schemas.xmlsoap.org/soap/envelope/" )
    mkp.declareNamespace( 'sic': "http://www.example.com/" )
    'soapenv:Envelope' {
        'soapenv:Header'()
        'soapenv:Body' {
            'sic:IncPrePrTyped' {
                'sic:clsProp' {
                    'sic:datDataSist'('2017-02-02')
                    'sic:datDataVali'('2017-02-02')
                    'sic:strEmpr'('01')
                    'sic:strProd'('0071')
                    'sic:strBand'('02')
                    'sic:strFil'('0001')
                    'sic:strPontAtend'('3424')
                    'sic:strAtend'('A5F1')
                    'sic:datDataProp'('2017-02-01')
                    'sic:strClient'('24517666034')
                    'sic:strName'('BENTO DA SILVA AMARAL')
                    'sic:strDataNasc'('27/06/1952')
                }
            }
        }
    }
}

println XmlUtil.serialize( writer )