Rails 如何在 Rails Controller 支持 SOAP?

alphaliu · September 29, 2013 · Last by AlphaLiu replied at September 29, 2013 · 3635 hits

我需要写一个 rails app,然后要支持一个客户端发过来的 soap 数据,要能够解析并且回复,请问有什么技术能做到吗?? 客户端发过来的 http 数据大致如下:

POST /ftacs-acs/acs HTTP/1.1
Accept: */*
Host: acs-tech.com
Connection: Keep-Alive
Content-type: text/xml; charset=UTF-8
Content-length: 233
SOAPAction: ""

<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
 <SOAP-ENV:Header>
  <cwmp:ID SOAP-ENV:mustUnderstand="1">291188</cwmp:ID>
 </SOAP-ENV:Header>
 <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/">
  <cwmp:Inform>
   <DeviceId>
    <Manufacturer>Arcadyan</Manufacturer>
    <OUI>0E0908</OUI>
    <ProductClass>HGW</ProductClass>
    <SerialNumber>JM20130922</SerialNumber>
   </DeviceId>
  </cwmp:Inform>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

目前我想到的就是在 ftacs-acs/acs 这个 controller 里面支持解析这么一大串数据,但是不知道要怎么解析,求教一下各位,谢谢。

#1 楼 @Rei 多谢 Rei 了,我是第一次知道这个地址...

奥,不过你好像是要做 soap server?这个分类大多数是 client。

如果没有就用 nokogiri 一类 xml 解析器分析了。

我前几天也做了一些这个方面的,服务端用的是 wash_out,商户端用 savon 都比较好用

https://github.com/inossidabile/wash_out

搜了一下这个可以用来做 server

#3 楼 @Rei 是的,应该算 server,因为现在这个客户端会向某个 url post soap 的数据,所以我想把这个 url 作为是一个 controller 的 action,在 action 里面解析数据会比较好。然后 action 还要回复 soap 数据给这个客户端。

#4 楼 @ZombieCoder@Rei了,我刚刚也搜到 wash_out,先来研究一下

You need to Sign in before reply, if you don't have an account, please Sign up first.