我正在向 Rails 网络服务提交以下消息:
xmlPostData = "<message>
<message-text>" + MESSAGE_WITH_XML + "</message-text>
<name>" + subject + "</name>
<f1>" + toPhone + "</f1>
<f2>" + fromPhone + "</f2>
</message>";
问题是包含带有 XML 数据的文本的字段是一种解决方法,但我需要能够将该 xml 提交到数据库并从那里获取它。
我可以停止 rails 以 json 格式验证和替换我的 xml 吗?这是它的样子:
--- !map:HashWithIndifferentAccess
smil: !map:HashWithIndifferentAccess
head: !map:HashWithIndifferentAccess
layout: !map:HashWithIndifferentAccess
root_layout: !map:HashWithIndifferentAccess
height: "600"
background_color: white
width: "800"
type: text/smil-basic-layout
body: !map:HashWithIndifferentAccess
par: !map:HashWithIndifferentAccess
text: !map:HashWithIndifferentAccess
left: "33"
begin: "33"
dur: "33"
val: 34343434343434343aaaaaaa
height: "33"
width: "33"
top: "33"
这是来自 rails webservice 的 ruby 方法:
# POST /messages
# POST /messages.xml
def create
@message = Message.new(params[:message])
respond_to do |format|
if @message.save
flash[:notice] = 'Message was successfully created.'
format.html { redirect_to(@message) }
format.xml { render :xml => @message, :status => :created, :location => @message }
else
format.html { render :action => "new" }
format.xml { render :xml => @message.errors, :status => :unprocessable_entity }
end
end
end
是一种解决方法,但目前这必须工作......