-
-
Save bensie/1138077 to your computer and use it in GitHub Desktop.
source "http://rubygems.org" | |
gem 'httpi', :git => 'git://github.com/bensie/httpi.git', :branch => 'ntlm' | |
gem 'savon' |
require 'rubygems' | |
require "bundler/setup" | |
require 'savon' | |
require 'pp' | |
SERVER = "nav" | |
PORT = 7047 | |
SERVER_INSTANCE = "DynamicsNAV" | |
COMPANY_NAME = "CompanyName" | |
BASE_PATH = "https://#{SERVER}:#{PORT}/#{SERVER_INSTANCE}/WS/#{COMPANY_NAME}" | |
HTTPI::Adapter.use = :net_http | |
client = Savon::Client.new do |wsdl, http| | |
wsdl.document = BASE_PATH + '/Page/orders' | |
http.auth.ntlm('user', 'domain', 'password') | |
http.auth.ssl.verify_mode = :none | |
end | |
# List available SOAP actions | |
pp client.wsdl.soap_actions | |
# Read | |
read = client.request :read do | |
soap.body = { "id" => 10000 } | |
end | |
# Create (with hash of attributes) | |
create_with_id = client.request :create do | |
soap.body = { "orders" => { "id" => 20000 } } | |
end |
I've updated this to an example that works -- it requires that you use my fork of HTTPI though -- I was unable to get NTLM to work with Navision using the released HTTPI lib.
I have not yet figured out how to create new objects with this in Navision, but reading, updating, and deleting is working well.
Updated once more to show how to successfully create objects in Navision - you need to pass the plural name of the object as a hash key with a hash of attributes as the value.
Hello Bensie,
Could you please put an example on how to create objects? Thank you.
Hey. This looks really interesting. I would really need my Web Service -call to make NTLM authentication. However couldn't get client initializing to work. Could you please tell me what savon version you are using?
Finally got this example working. I got this working when I downgraded my Savon to version 0.9.11. I hope NTLM support will come also to newer versions soon! Here's my GEMFILE which worked for me:
gem 'httpi', :git => 'git://github.com/bensie/httpi.git', :branch => 'ntlm'
gem "pyu-ntlm-http", :git => "git://github.com/lxcid/ntlm-http.git", :branch =>"1.9_utf16_bom_fix"
gem 'savon', '~> 0.8'
I guess last line could of course also be:
gem 'savon', '~> 0.9'
Hello,
I am trying to consume web services of dynamics nav using following gems
gem 'httpi', :git => 'git://github.com/bensie/httpi.git', :branch => 'ntlm'
gem 'savon'
but I am not able to consume web services of dynamics nav.
I got following error
[1] pry(#Api::Services::ServicesController)> client.wsdl.soap_actions
D, [2016-02-24T19:23:18.013211 #20648] DEBUG -- : HTTPI executes HTTP GET using the net_http adapter
Savon::HTTP::Error:
from /home/.rvm/gems/ruby-2.2.2/gems/savon-0.9.11/lib/savon/wasabi/document.rb:36:in `resolve_document'
Could you please help me to solve this issue or consuming web services of dynamics nav?
Thanks,
Kapil
Hello!
I'm also trying to access Navision web-services using savon. Did you manage to get this to work?
I am getting [] for soap_actions