2
SOAP API에 요청을 보내기위한 간단한 루비 스크립트를 얻으려고하지만 응답을 다시받을 수 없습니다. 나는 컬을 통해 동일한 요청을 보낼 때 (작동, 그러나SOAP + SSL + Ruby Savon - HTTPClient :: ConnectTimeoutError : 실행 만료
D, [2011-05-05T10:21:45.014588 #22136] DEBUG -- : SOAP request: "http://www.example.com"
D, [2011-05-05T10:21:45.014743 #22136] DEBUG -- : Content-Type: text/xml;charset=UTF-8, SOAPAction: "getData"
D, [2011-05-05T10:21:45.014787 #22136] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?><env:Envelope ...(XML request)... </env:Body></env:Envelope>
D, [2011-05-05T10:21:45.014864 #22136] DEBUG -- : HTTPI executes HTTP POST using the httpclient adapter
HTTPClient::ConnectTimeoutError: execution expired
복사 :
require 'date'
require 'savon'
# Create the client
client = Savon::Client.new do
wsdl.document = File.expand_path("path to wsdl document", __FILE__)
end
# Setup namespaces and credentials
client.wsdl.namespace = "http://www.example.com"
client.wsse.credentials "[USERNAME]", "[PASSWORD]"
# Setup ssl configuration
client.http.auth.ssl.cert_key_file = "path to key pem file"
client.http.auth.ssl.cert_file = "path to cert pem file"
client.http.auth.ssl.verify_mode=:peer
# execute request
response = client.request :sub, :get_data do
soap.body = {"sub:id" => "123456"}
end
이 요청과 함께 완료 :
이
은 내가 뭘하려고 오전입니다 위의 xml 요청을 soap-request.xml 파일에) :curl -k -v --header "Content-Type: text/xml;charset=UTF-8, SOAPAction: 'getData'" https://www.example.com [email protected] --cert-type PEM --cert path_to_pem_file_with_both_key_and_cert
내가 루비 스크립트에서 누락 된 것에 대한 아이디어 ?
미리 감사드립니다.
업데이트 :
위 코드는 WSDL 문서가 올바른 경우 작동합니다. 다만, 하나가 아니거나 경우에이 오류, 그냥이와 클라이언트 선언을 대체 :
# Create the client
client = Savon::Client.new do
wsdl.endpoint = "https://whateverendpoint.com"
wsdl.namespace = "http://whatevernamespace.com"
end
마지막으로, 또한 좋은 아이디어를 가능한 오류를 잡기 위해 Savon의 문서에 설명 된대로 :
를begin
# execute request
response = client.request :sub, :get_data do
soap.body = {"sub:id" => "123456"}
end
rescue Savon::SOAP::Fault => fault
puts fault.to_s
end
나는 타임 아웃을 연장하려고 시도했지만 작동하지 않았다. 그러나 웹에서 wsdl 문서에 문제가있을 수 있다는 사실을 읽었습니다. 나는 잘못된 문서를 받았다. 방금 wsdl 문서 선언을 제거하고 wsdl 끝점과 네임 스페이스를 클라이언트 선언에 추가했습니다. 이제 작동합니다. 어쨌든 귀하의 의견을 보내 주셔서 감사합니다. 위의 수정 사항을 추가합니다. – carvil