我正在使用基于SOAP的Web服务。我正在使用Savonrb通过POST请求调用服务。我正在使用Nokogiri构建XML并使用Savonrb将其发送到服务。
我的应用程序是使用Rails 3.1构建的。该服务正在我的本地主机上运行,但是当我们在生产中测试它时出现间歇性错误,我收到以下错误:
TypeError (Nokogiri::XML::Namespace can't be coerced into Nokogiri::XML::Namespace)
有谁能让我知道错误信息的含义?
这是我构建它的代码:
builder = Nokogiri::XML::Builder.new
builder.Envelope{
builder.parent.namespace = builder.parent.add_namespace_definition("soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
builder['soapenv'].Body{
builder['ns0'].GetParty("xmlns:ns0" => "http://www.cisco.com/cixs2.0/oagis", "xmlns:ns1" => "http://www.openapplications.org/oagis/9"){
builder['ns1'].ApplicationArea{
builder['ns1'].Sender{
builder['ns1'].LogicalID_ sender_information['LogicalID']
builder['ns1'].ComponentID_ sender_information['ComponentID']
builder['ns1'].TaskID_ sender_information['TaskID']
builder['ns1'].ReferenceID_ sender_information['ReferenceID']
builder['ns1'].AuthorizationID_ sender_information['AuthorizationID']
}
builder['ns1'].CreationDateTime_ DateTime.now.to_s('yyyy-MM-ddTHH:mm:sszzz')
builder['ns1'].BODID(1214201110)
}
builder['ns0'].DataArea{
builder['ns0'].Get(get_condition){
builder['ns1'].Expression('expressionLanguage' => "String" ){
builder.text "All"
}
builder.__send__ :insert, Nokogiri::XML::DocumentFragment.parse(hierarchy)
builder.__send__ :insert, Nokogiri::XML::DocumentFragment.parse(search_condition)
builder['ns0'].SearchCriteria{
builder['ns0'].MatchAlgorithm("EXACT_SEARCH")
builder.__send__ :insert, Nokogiri::XML::DocumentFragment.parse(search_type)
builder['ns0'].SearchSource(search_source){
builder.text "DEFAULT"
}
builder['ns0'].ParallelSearchIndicator('true')
builder['ns0'].StopWhenResultFoundIndicator('true')
}
}
}
}
}
}
return builder.to_xml
答案 0 :(得分:0)
有谁能让我知道错误信息的含义?
是 - FUBAR。我要尝试的第一件事是文档中的示例(向下滚动到Namespaces部分):
http://nokogiri.org/Nokogiri/XML/Builder.html
如果这不起作用,请查看这里的想法: