Answer the question
In order to leave comments, you need to log in
How to generate xml in ruby on rails with savon gem?
Hello! on duty, I had to deal with SOAP, now I understand why they don’t like Gates, I can’t understand how it all works in general, it is necessary to form a request to a remote server with the following content:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esf="esf">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-664678CEF9FFC67AD214168421472821">
<wsse:Username>123456789011</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security></soapenv:Header>
<soapenv:Body>
<esf:createSessionRequest>
<tin>?</tin>
<!--Optional:-->
<projectCode>?</projectCode>
<x509Certificate>?</x509Certificate>
</esf:createSessionRequest>
</soapenv:Body>
</soapenv:Envelope>
client = Savon.client(wsdl: "https://212.154.167.194:9443/esf-web/ws/api1/SessionService?wsdl",
ssl_verify_mode: :none,
env_namespace: :soapenv,
pretty_print_xml: true,
env_namespace: :soapenv,
:raise_errors => true,
log: true,
#loglevel: :debug,
:soap_header => {
"wsse:Security" => {
"@xmlns:wsse" => "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
"@xmlns:wsu" => "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
"@soapenv:mustUnderstand" => "1",
"wsse:UsernameToken" => {
"wsse:Username" => "foo",
"wsse:Password" => "bar"
}
}
})
message = {
"createSessionRequest" =>
{
"tin" => "placeholder",
"x509Certificate" => "placeholder"
}
}
response = client.call(:create_session, message: {:tin => 'XXXX', :x509Certificate => 'xxxxxx'})
Answer the question
In order to leave comments, you need to log in
I assume that the problem is related to the spoofing of the SSL certificate in the .kz zone (I checked the URL in the browser):
NET::ERR_CERT_COMMON_NAME_INVALID
Subject: ESF.GOV.KZ
Issuer: ҰLTTYҚ KUALANDYRUSHY ORTALYҚ (RSA)
Expires on: Feb 11, 2017
Current date: Sep 26, 2017
Here, as a bad option, you can ignore the SSL certificate check and then, perhaps, the request will work.
You can catch the error code like this :
begin response = client.call(:create_session, message: {:tin => 'XXXX', :x509Certificate => 'xxxxxx'}) rescue Savon::SOAPFault => error fault_code = error.to_hash[:fault][:faultcode] raise CustomError, fault_code end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question