Вопрос

I'm trying to work with the SOAP API of a certain vendor (ExamOne). They have a wsdl, and I am trying to use Savon (2.2.0) to interface with them, and although I am reading the Savon doc, I cannot see how to get the XML output to match the sample request that ExamOne sent me.

For instance, ExamOne prescribes the following for the root node tag:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eos="http://QuestWebServices/EOService">

...but Savon gives me the following:

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://QuestWebServices/EOService" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">

I'm sorry to ask such a dumb question, but I find the Savon documentation altogether unhelpful, and I am lost. Can anyone tell me how to correct the namespaces ('soapenv' instead of 'env')? Can anyone tell me how to get the root node to have the correct attributes?

TMI: Ruby v 1.9.3, Rails 3.2.13

Это было полезно?

Решение 2

Working Code:

wsdl = Savon.client(
  wsdl:APP_CONFIG['exam_one']['wsdl'],
  env_namespace:'soapenv',
  namespace_identifier:'eos',
  logger:Logger.new("#{Rails.root}/log/exam_one_or01.log", 1, (2097152*10))
  )
message = {
  :username => APP_CONFIG['exam_one']["username"],
  :password => APP_CONFIG['exam_one']["password"],
  :destinationID => "C1",
  :payload => self.to_s
}
@response = wsdl.call :deliver_exam_one_content, message:message, raise_errors:false

The solution:

The problem, it turns out, was that Savon was raising an error because of the 400 response, and as a consequence of the error, it was not logging its own request. (Poor design choice, I think.)

The solution was to include the option raise_errors: false in the params for call on the clientclient.

To get the namespaces I needed, I had to include: env_namespace:'soapenv', namespace_identifier:'eos'. (I know, I didn't mention the latter issue in my original question, but that's how to namespace items in the payload.)

(+1 to Steven for a correct demonstration of env_namespace.)

Другие советы

Start with this snippet:

#!ruby
#
gem 'savon', '~> 2.0'
require 'savon'

client = Savon.client(
    wsdl: 'https://wssim.labone.com/services/eoservice.asmx?WSDL',
    env_namespace: :soapenv,
    log: true,
    log_level: :debug,
    pretty_print_xml: true
)

p client.operations

response = client.call(:loop_back)

p response.to_hash
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top