-
-
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 |
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 Bensie,
Could you please put an example on how to create objects? Thank you.