如何使用wslite soap api使用nil

时间:2015-02-16 11:22:27

标签: grails soap null

Grails 2.4.4 + wslite 0.7.2.0允许您这样调用SOAP服务:

    def client = new SOAPClient('http://www.webservicex.net/CurrencyConvertor.asmx')
    def response = client.send(SOAPAction:'http://www.webserviceX.NET/ConversionRate') {
        body {
            ConversionRate('xmlns':'http://www.webserviceX.NET/') {
                FromCurrency('GBP')
                ToCurrency('EUR')
            }
        }
    }

问题是我正在调用一个需要使用nil的服务,例如

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
          xmlns:ns="bla" xmlns:i="w3.org/2001/XMLSchema-instance">
   :
 <ns:IdentityToken i:nil="true"></ns:IdentityToken>

是否有使用该插件执行此操作?

1 个答案:

答案 0 :(得分:1)

想出来。我不知道这是否正确,但似乎对我们的服务有用。以下仅用于说明使用nil的策略:

def client = new SOAPClient('http://www.webservicex.net/CurrencyConvertor.asmx')
def response = client.send(SOAPAction:'http://www.webserviceX.NET/ConversionRate') {
    body {
        ConversionRate('xmlns':'http://www.webserviceX.NET/' , 'xmlns:i': "http://www.w3.org/2001/XMLSchema-instance") {
            FromCurrency("i:nil": "true", '')
            ToCurrency('EUR')
        }
    }
}