代码之家  ›  专栏  ›  技术社区  ›  acemutha

使用ssl基本身份验证和客户端证书帮助soap响应

  •  4
  • acemutha  · 技术社区  · 15 年前

    您好,我正在尝试使用ssl、客户端证书和基本身份验证向受保护的wsdl和web服务发出一个简单的请求。

    这是密码

    require 'savon'
    
    client = Savon::Client.new "https://example.com/service?wsdl"
    
    client.request.http.ssl_client_auth(
    :cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
    :key => OpenSSL::PKey::RSA.new(File.read("key.pem")),
    :verify_mode => OpenSSL::SSL::VERIFY_NONE
    )
    client.request.basic_auth "User", "Password"
    
    response = client.AddCustomer |soap|
    soap.body = {
    :Channel => 0,
    :tel => '34567',
    :id => '597118125',
    :paymentMode => 1,
    :Alias => 666,
    :flag => 0
    }
    
    puts response.to_xml
    

    使用soapui的工作测试信封是:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mov="http://www.example.com/services/">
    <soapenv:Header/>
    <soapenv:Body>
    <asd:AddCustomer>
    <Channel>0</idChannel>
    <tel>12344</msisdn>
    <id>59711</idIssuer>
    <paymentMode>1</paymentMode>
    <Alias>666</idAlias>
    <flag>0</flagPrivacy>
    </asd:AddCustomer>
    </soapenv:Body>
    </soapenv:Envelope>
    

    当我运行代码时,会出现以下错误:

    method_missing': undefined method `AddCustomer' for #<Savon::Client:0x8abec08>
    
    1 回复  |  直到 14 年前
        1
  •  3
  •   Beanish    15 年前

    试着打印以下内容-或者直接在IRB中打印

    client.wsdl.soap_actions
    

    我猜你会发现addcustomer不是一个。可能已经改成了add_customer。