방금 HTTParty를 사용하기 시작했으며 서버에서 응답 한 XML에서 해시를 만드는 방식에 문제가 발생했습니다.XML 및 HTTParty 문제
있다면 설치 서버에서 다음 빌더 템플릿 :
xml.thunt :sendSubscriptionResult, :"xmlns:thunt" => "http://example.com/thunt", :status => @status
모든 HTTParty에 의해 만들어진 해시 빌더에 의해 생성 된 XML, (같은 요청을 관찰 할 수있다 후자의 일치, 즉, 잘 작동 비아 컬)
컬 요청
curl -s -H "Accept: text/xml" -d "xml=`cat vendor/testxml/requests/sendsubscription.xml`" $SERVER/${name}
REPL Y HTTParty
{"thunt:sendSubscriptionResult"=>{"status"=>"alreadySubscribed", "xmlns:thunt"=>"http://example.com/thunt"}}
그러나에
'<thunt:sendSubscriptionResult xmlns:thunt="http://example.com/thunt" status="alreadySubscribed" />'
컬
HTTParty 요청
TreasureHunt.post('/sendsubscription', :query => { :xml => sub })
응답하여 보듯
xml.thunt :sendSubscriptionResult, "Hello, World", :"xmlns:thunt" => "http://example.com/thunt", :status => @status
(이하 "안녕, 세계"추가 주) 두 가지 도구가 갑자기 반대 : 빌더에서 내가 원하는 것을 지정하는 경우 sendSubscriptionResult 요소는 텍스트 노드를 가질 수 있습니다.
컬
'<thunt:sendSubscriptionResult xmlns:thunt="http://example.com/thunt" status="alreadySubscribed">Hello, World</thunt:sendSubscriptionResult>'
HTTParty
{"thunt:sendSubscriptionResult"=>"Hello, World"}
당신이 볼 수 있듯이, HTTParty은 요소의 속성을 모두 제거하고 있으며, 그 결과 해시
만 텍스트 노드를했다HTTParty의 버그입니까? 아니면 잘못된 것입니까? 감사합니다.
저는 XML과 HTTParty에 문제가 없었으므로이 질문에 대한 확실한 답변을보고 싶습니다. – tadman