Skip to content

Instantly share code, notes, and snippets.

@bensie
Created August 10, 2011 20:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bensie/1138077 to your computer and use it in GitHub Desktop.
Save bensie/1138077 to your computer and use it in GitHub Desktop.
savon ntlm
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
@ffomenko
Copy link

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

@bensie
Copy link
Author

bensie commented Sep 20, 2011

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.

@bensie
Copy link
Author

bensie commented Sep 22, 2011

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.

@JNad
Copy link

JNad commented Feb 8, 2013

Hello Bensie,

Could you please put an example on how to create objects? Thank you.

@marttihyvonen
Copy link

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?

@marttihyvonen
Copy link

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'

@marttihyvonen
Copy link

I guess last line could of course also be:
gem 'savon', '~> 0.9'

@kapilchothe
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment