我正在使用基于 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