使用Grails的SOAP客户端请求
问题描述:
我尝试使用SOAP为ipayment(德国)创建支付系统,并在其文档中描述了使用以下SOAP请求可能会得到第二个代码示例中显示的响应。从服务器使用Grails的SOAP客户端请求
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<capture>
<accountData>
<accountId>99999</accountId>
<trxuserId>99999</trxuserId>
<trxpassword>0</trxpassword>
<adminactionpassword>
5cfgRT34xsdedtFLdfHxj7tfwx24fe</adminactionpassword>
</accountData>
<origTrxNumber>1-25949395</origTrxNumber>
<transactionData>
<trxAmount>119</trxAmount>
<trxCurrency>EUR</trxCurrency>
</transactionData>
</capture>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
而且例如响应
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:captureResponse
xmlns:ns1="https://ipayment.de/service_v3/binding">
<ipaymentReturn>
<status>SUCCESS</status>
<successDetails>
<retTransDate>25.07.08</retTransDate>
<retTransTime>17:08:08</retTransTime>
<retTrxNumber>1-25949407</retTrxNumber>
<retAuthCode></retAuthCode>
</successDetails>
<addressData>
<addrStreet>Ernst-Frey-Str. 9</addrStreet>
<addrCity>Karlsruhe</addrCity>
<addrZip>76135</addrZip>
<addrCountry>DE</addrCountry>
</addressData>
<addresscheckResult>UNCHECKED</addresscheckResult>
<paymentMethod>VisaCard</paymentMethod>
<trxPaymentDataCountry>US</trxPaymentDataCountry>
</ipaymentReturn>
</ns1:captureResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但我不知道如何如图所示使用Grails创建请求。我尝试使用Spring WS插件,但文档中的示例代码根本没有帮助。你知道任何来源的例子或任何想法? WSDL架构可以在https://ipayment.de/service/3.0/?wsdl 谢谢。
答
如果不需要cookie验证WS(而且他们不应该:-)),则groovy-wslite是一个很好的库,用于创建SOAP请求。
另一种方法是使用HTTPBuilder它允许你创建旅游确切的请求和处理cookie如果需要的话(你可以做到这一点与wslite,但有一点更多的工作)
答
如果你是脚本,小费可能直接从groovy使用curl(如果有的话)。它非常强大,易于操作,并且可以一次完成。
如: “卷曲-d \” $ {有效载荷} \ “-H \ ”内容类型:文本/ XML \“ $ {} wsUrl” execute.text 当有效载荷的要求(包括肥皂信封)。
这有帮助,谢谢。 – ufucuk 2012-07-09 10:39:08