为什么请求发送错误Savon :: SOAPFault:(ns1:SecurityError)

时间:2017-09-24 21:04:40

标签: ruby-on-rails soap-client savon

我从SOAP操作集成中收到此错误。 Savon :: SOAPFault:(ns1:SecurityError)验证消息时遇到安全性错误

我的Savon客户端看起来像这样:

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,
        namespace_identifier: :nam, 
        env_namespace: :soapenv,
        namespaces: { "xmlns:nam" => "namespace.esf" },
        :raise_errors => true,
        log: true,
        #loglevel: :debug,
        pretty_print_xml: true)
        message = {
  "createSessionRequest" =>
  {
    "tin" => "placeholder",
    "x509Certificate" => "placeholder"
  }
} 

并生成响应

response = client.call(:create_session, message: {:tin => 'XXXX', :x509Certificate => 'xxxxxx'}) 

XML代码应该在这里:

<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>

请帮忙

1 个答案:

答案 0 :(得分:0)

在xml中,您拥有以下用户名和密码

<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>            

您在哪里设置这些用户名和密码?

Read the guide以便您可以按照他们的步骤配置Savon:

response = client.call(:authenticate, message: { username: "luke", password: "secret" })