我试图解析来自Savon SOAP api的SOAP响应
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getConnectionResponse xmlns:ns="http://webservice.jchem.chemaxon">
<ns:return>
<ConnectionHandlerId>connectionHandlerID-283854719</ConnectionHandlerId>
</ns:return>
</ns:getConnectionResponse>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
我试图使用libxml-ruby而没有任何成功.基本上我想提取标签内的任何内容和connectionHandlerID值.
当您使用Savon时,您可以将响应转换为哈希.转换方法response.to_hash也为您做了一些其他有用的事情.
然后,您可以使用类似于以下内容的代码获取所需的值
hres = soap_response.to_hash
conn_handler_id = hres[:get_connection_response][:return][:connection_handler_id]
Run Code Online (Sandbox Code Playgroud)
查看文档
| 归档时间: |
|
| 查看次数: |
2492 次 |
| 最近记录: |