consume custom binding oracle WFC web service with ruby / savon - ruby

I am trying to consume a wfc web service with a non basicthttp binding with ruby and savon.
The provider of the WS implemented the oracle/wss11_username_token_with_message_protection_service_policy (which is described here
http://www.oracle.com/technetwork/articles/soa/oracle-msft-interoperate-183511.html)
If I understand correctly this policy is expecting some sort of encryption (according to this http://blog.raastech.com/2012/08/owsm-security-errors.html) due to the non basic http binding
The WS described actually goes over ssl which may be the root of all evil due to me implementing it poorly.
Is even possible to consume a WFC WS with non basic http binding with savon?
My background is ruby and rails, yet I am new to WS (and savon) and ssl usage.
Now the provider of the WS does not give much of support. Actually their outing is that they only provide support for implementations in java or .net (is that even possible given that it’s a WS and thus platform independent?).
In an attempt to run the fairly simple code which is the following
require 'savon'
client = Savon.client do
wsdl "https://apps.ika.gr/hospitalisationWSS_TEST-hospitalisationWSS_TEST-context-root/MainWSClassPort?WSDL"
wsse_auth "ΥΥΥΥ", "ΧΧΧΧ" # ALTERED
wsse_timestamp true
pretty_print_xml true
log_level :debug
ssl_verify_mode :none
ssl_cert_file "files/ika.cer" # provided by WS provider
end
save_admission_hl7_msg = "MSH|^~\&|||||201310111112||ADT^A13^ADT_A13|2013000012113|P|2.6|||||||||66645678912345678945|^^^^^^^^^10000\nEVN|A13|201310101122|||nosiliapap\nPID\nPV1||I|||||||||||||||||2013000012111|||||||||||||||||||||||||||||||2013000012113\n"
response = client.call(:save_admission_hl7,
:attributes => { :xmlns => "http://bean.intracom.com/" },
:message => { :arg0 => { :#xmlns=>'', :content! =>{ :hl7ADT => save_admission_hl7_msg } } } )
end
puts response.body
Ι get the following output
D, [2013-12-04T08:21:20.445549 #3088] DEBUG -- : HTTPI GET request to apps.ika.gr (httpclient)
I, [2013-12-04T08:21:22.074643 #3088] INFO -- : SOAP request: https://apps.ika.gr/hospitalisationWSS_TEST-hospitalisationWSS_TEST-context-root/MainWSClassPort
I, [2013-12-04T08:21:22.074643 #3088] INFO -- : SOAPAction: "saveAdmissionHl7", Content-Type: text/xml;charset=UTF-8, Content-Length: 1363
D, [2013-12-04T08:21:22.075643 #3088] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://bean.intracom.com/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">
<wsse:Username>YYYY</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXX</wsse:Password>
</wsse:UsernameToken>
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-2">
<wsu:Created>2013-12-04T06:21:22Z</wsu:Created>
<wsu:Expires>2013-12-04T06:22:22Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</env:Header>
<env:Body>
<tns:saveAdmissionHl7 xmlns="http://bean.intracom.com/">
<arg0 xmlns="">
<hl7ADT>MSH|^~&|||||201310111112||ADT^A13^ADT_A13|2013000012113|P|2.6|||||||||66645678912345678945|^^^^^^^^^10000
EVN|A13|201310101122|||nosiliapap
PID
PV1||I|||||||||||||||||2013000012111|||||||||||||||||||||||||||||||2013000012113
</hl7ADT>
</arg0>
</tns:saveAdmissionHl7>
</env:Body>
</env:Envelope>
D, [2013-12-04T08:21:22.076643 #3088] DEBUG -- : HTTPI POST request to apps.ika.gr (httpclient)
I, [2013-12-04T08:21:22.472665 #3088] INFO -- : SOAP response (status 500)
D, [2013-12-04T08:21:22.473665 #3088] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:Fault xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
<faultcode xmlns:ns0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ns0:FailedCheck</faultcode>
<faultstring>FailedCheck : failure in security check</faultstring>
</ns2:Fault>
</S:Body>
</S:Envelope>
f:/rubystack/ruby/lib/ruby/gems/1.9.1/gems/savon-2.3.0/lib/savon/response.rb:85:in `raise_soap_and_http_errors!': (ns0:FailedCheck) FailedCheck : failure in security check (Savon::SOAPFault)
from f:/rubystack/ruby/lib/ruby/gems/1.9.1/gems/savon-2.3.0/lib/savon/response.rb:14:in `initialize'
from f:/rubystack/ruby/lib/ruby/gems/1.9.1/gems/savon-2.3.0/lib/savon/operation.rb:64:in `new'
from f:/rubystack/ruby/lib/ruby/gems/1.9.1/gems/savon-2.3.0/lib/savon/operation.rb:64:in `create_response'
from f:/rubystack/ruby/lib/ruby/gems/1.9.1/gems/savon-2.3.0/lib/savon/operation.rb:55:in `call'
from f:/rubystack/ruby/lib/ruby/gems/1.9.1/gems/savon-2.3.0/lib/savon/client.rb:36:in `call'
from eopyy.rb:82:in `<main>'
Now given my poor knowledge on WS's and SSL usage I cant figure out the error.
Is it the SSL? Should I use ssl_ca_cert_file instead of ssl_cert_file ? (obviously I tried that already). Do I need to use a key file also?
The provider actually provides a .jks file (next to the above "ika.cer" certificate) but also mentions that it should be used only within a java implementation (an not a .net). I already unpacked the jks file and attempted to use its contained certificates and files, unsuccesfully.
Any help, clues, tips, greatly appreciated.

Related

invalid SOAP request needs experienced eye

TLDR: the solution can be found here
I'm using savon to make requests against a SOAP service. I know... Gross.
Regardless, I'm having trouble making Savon behave. The SOAP provider has this validator, which takes the following inputs:
Web Service: ProductData
Version: 1.0.0
Operation: getProductSellable
Endpoint: https://psproductdata100-stg.pcna.online
When I use the validator, I enter this xml:
<GetProductSellableRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/">
<wsVersion xmlns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/SharedObjects/">1.0.0</wsVersion>
</GetProductSellableRequest>
And I get this response body
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetProductSellableResponse xmlns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/">
<ErrorMessage xmlns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/SharedObjects/">
<code>110</code>
<description>Authentication Credentials Required</description>
</ErrorMessage>
</GetProductSellableResponse>
</s:Body>
</s:Envelope>
That response is valid because I did not provide my un/pw. If I do provide credentials, I get a full response. Below is a screenshot of that happening in my browser.
However, when I use Savon to make the same request
#!/usr/bin/env ruby
require 'savon'
require 'awesome_print'
require 'byebug'
require 'pry'
endpoint = 'https://psproductdata100-stg.pcna.online'
path = 'psProductData.svc?singleWsdl'
wsdl = "#{endpoint}/#{path}"
args = {
wsdl: wsdl,
log: true,
log_level: :debug,
pretty_print_xml: true,
element_form_default: :qualified
}
client = Savon.client(args) do
convert_request_keys_to :lower_camelcase
end
message = { ws_version: '1.0.0' }
response = client.call(:get_product_sellable) do
message(message)
end
ap response
The response does not come back as expected. The XML looks close to what was sent by the validator, but not exact.
Heres the request
D, [2018-04-26T18:01:00.471662 #89854] DEBUG -- : HTTPI /peer GET request to psproductdata100-stg.pcna.online (net_http)
I, [2018-04-26T18:01:00.979809 #89854] INFO -- : SOAP request: https://psproductdata100-stg.pcna.online/psProductData.svc
I, [2018-04-26T18:01:00.979886 #89854] INFO -- : SOAPAction: "getProductSellable", Content-Type: text/xml;charset=UTF-8, Content-Length: 501
D, [2018-04-26T18:01:00.980107 #89854] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/SharedObjects/">
<env:Body>
<tns:GetProductSellableRequest>
<tns:wsVersion>1.0.0</tns:wsVersion>
</tns:GetProductSellableRequest>
</env:Body>
</env:Envelope>
And the response
D, [2018-04-26T18:01:00.980224 #89854] DEBUG -- : HTTPI /peer POST request to psproductdata100-stg.pcna.online (net_http)
I, [2018-04-26T18:01:01.650449 #89854] INFO -- : SOAP response (status 200)
D, [2018-04-26T18:01:01.650731 #89854] DEBUG -- : <?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetProductSellableResponse xmlns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/">
<ErrorMessage xmlns="http://www.promostandards.org/WSDL/ProductDataService/1.0.0/SharedObjects/">
<code>110</code>
<description>Version mismatch.</description>
</ErrorMessage>
</GetProductSellableResponse>
</s:Body>
</s:Envelope>
and the output from Savon
{
:get_product_sellable_response => {
:error_message => {
:code => "110",
:description => "Version mismatch.",
:#xmlns => "http://www.promostandards.org/WSDL/ProductDataService/1.0.0/SharedObjects/"
},
:#xmlns => "http://www.promostandards.org/WSDL/ProductDataService/1.0.0/"
},
:"#xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
:"#xmlns:xsd" => "http://www.w3.org/2001/XMLSchema"
}
Thanks to the other answers on this thread, I found this post. I read up on how namespaces work, as well as linked XSD files. By combining my new knowledge with that post, I was a able to build out something like this:
require 'savon'
require 'awesome_print'
require 'byebug'
require 'pry'
endpoint = 'https://psproductdata100-stg.pcna.online'
path = 'psProductData.svc?singleWsdl'
wsdl = "#{endpoint}/#{path}"
args = {
wsdl: wsdl,
log: false,
log_level: :debug,
pretty_print_xml: true,
element_form_default: :qualified
}
client = Savon.client(args) do
convert_request_keys_to :lower_camelcase
namespaces 'xmlns:shar' => 'http://www.promostandards.org/WSDL/ProductDataService/1.0.0/SharedObjects/'
end
message = {
'shar:wsVersion' => '1.0.0',
'shar:id' => 'REDACTED',
'shar:password' => 'REDACTED'
}
response = client.call(:get_product_sellable) do
message(message)
end
ap response.body[:get_product_sellable_response][:product_sellable_array][:product_sellable][0..2]
Now i'm more fun to talk to at dinner parties.
Similar problem with namespaces ruby savon and wsdl namespacing. I believe you have the same problem.
Additional Note: Try to use SOAP UI to debug, the generated XML from the WSDL and see the difference. Also change the XML to the XML generated from the code and validate the XML in SOAP UI. It will show the errors if any in SOAP UI, will make debugging faster and errors more understandable.
I believe your issue is a namespace problem. The wsVersion is within the shared object namespace "ins0". It is not in the "tns" namespace. Try changing your request to look like the following:
<env:Body>
<tns:GetProductSellableRequest>
<ins0:wsVersion>1.0.0</ins0:wsVersion>
</tns:GetProductSellableRequest>
</env:Body>

SOAP fault when integrating with Swedish BankId

I'm trying to integrate with BankId (it's a common authentication and signing service in Sweden). I'm using Savon Ruby SOAP client and trying to make requests to the BankId's testing API following their guidelines. When making a call to an 'authenticate' operation, I am getting the following error:
The given SOAPAction Authenticate does not match an operation
The SOAP request looks as such:
SOAP request: https://appapi.test.bankid.com/rp/v4
SOAPAction: "Authenticate", Content-Type: text/xml;charset=UTF-8, Content-Length: 384
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rp="http://bankid.com/RpService/v4.0.0/types/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<rp:AuthenticateRequest>
<personalNumber>12345678</personalNumber>
</rp:AuthenticateRequest>
</env:Body>
</env:Envelope>
I'm creating a session using the following details:
wsdl: 'https://appapi.test.bankid.com/rp/v4?wsdl'
namespace: 'http://bankid.com/RpService/v4.0.0/types/'
endpoint: 'https://appapi.test.bankid.com/rp/v4'
Here's the code:
> client = Savon.client(wsdl: 'https://appapi.test.bankid.com/rp/v4?wsdl', namespace: 'http://bankid.com/RpService/v4.0.0/types/', endpoint: 'https://appapi.test.bankid.com/rp/v4', ssl_cert_file: "XXXX/cert.pem", ssl_cert_key_file: "XXX/key.pem", ssl_cert_key_password: "qwerty123", pretty_print_xml: true, log_level: :debug, log: true)
> client.call(:authenticate, message: {personalNumber: '12345678'})
I should mention that I'm am not highly familiar with using SOAP API.
I just needed to explicitly say that soap_action header was not required.
> client = Savon.client(wsdl: 'https://appapi.test.bankid.com/rp/v4?wsdl', namespace: 'http://bankid.com/RpService/v4.0.0/types/', endpoint: 'https://appapi.test.bankid.com/rp/v4', ssl_cert_file: "XXXX/cert.pem", ssl_cert_key_file: "XXX/key.pem", ssl_cert_key_password: "qwerty123", pretty_print_xml: true, log_level: :debug, log: true)
> client.call(:authenticate, message: {personalNumber: '12345678'}, soap_action: '')

How to call a SOAP Web Service using Ruby Savon?

I am trying to call a web service using Savon.
The request I am trying to generate is this (this is a valid request that is working, generated with wizdler):
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<FraudValidationRequest xmlns="http://schemas.gid.gap.com/fraudvalidation/v3">
<OrderHeader xmlns="">
<EntryType>1</EntryType>
.... more attributes
But I get something like this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://schemas.gid.gap.com/fraudvalidation/v3"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<wsdl:validateOrder>
<fraudValidationRequest>
<orderHeader>
<entryType>1</entryType>
</orderHeader>
</fraudValidationRequest>
</wsdl:validateOrder>
</env:Body>
</env:Envelope>
So I get this error in the server side (the web service is implemented in java):
org.apache.axis2.databinding.ADBException: Unexpected subelement FraudValidationRequest
This is my client code in ruby:
require "savon"
URL = 'http://localhost:8080/MockFraudValidationServiceProvider/services/FraudValidationServiceV3'
begin
client = Savon.client do
# wsdl URL + "?wsdl"
endpoint URL
namespace "http://schemas.gid.gap.com/fraudvalidation/v3"
log_level :debug
pretty_print_xml :true
end
response = client.call(:validate_order,
message: {
FraudValidationRequest: { OrderHeader: { EntryType: 1 } }
}
)
puts response.to_hash;
end
I have tried several things: wsdl, endpoint and namespace, with/without namespace, camelcase or not, etc. but I can't generate the appropriate request.
I am not expert on SOAP (obviously), I understand that if there is a WSDL (my case) there is no need to set the namespace, but I am not sure. When I try using only WSDL I get this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:types="http://services.gid.gap.com/fraudvalidation/v3"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ins0="http://schemas.gid.gap.com/fraudvalidation/v3">
<env:Body>
<types:FraudValidationRequest>
<fraudValidationRequest>
<orderHeader>
<entryType>1</entryType>
</orderHeader>
</fraudValidationRequest>
</types:FraudValidationRequest>
</env:Body>
</env:Envelope>
Please advice, I hope I was clear.
Have you tried this?
require 'savon'
# create a client for the service
client = Savon.client(wsdl: 'http://service.example.com?wsdl')
p client.operations
# => [:find_user, :list_users]
# call the 'findUser' operation
response = client.call(:find_user, message: { id: 42 })
response.body
# => { find_user_response: { id: 42, name: 'Hoff' } }
client operations are the ones you can call, simply you can print them and check to call the right one.
message is a client parameter were you put your params, you can also set it this way:
params = {
:param_1 => "value",
_param_2 => 7
}
response = client.call(:find_user, message: params)
I use this code and I was able to call my Web Service

Savon 2.1.0 basic auth not functioning

I am trying to access a SOAP service which has the following charateristics:
1. WSDL is available without authentication
2. The service is accessible over https with basic_auth
3. According to the SOAP service, the "Authorization" header needs to be included in every request
Here is my code for construction the soap client:
#wsdl="https://example.com/table.do&WSDL"
#proxy="http://internal.proxy.com:8080"
#basic_auth=["user","pass"]
#headers={"Authorization" => "Basic"}
client = Savon.client do |globals|
globals.wsdl #wsdl
globals.proxy #proxy
globals.basic_auth #basic_auth
globals.headers #headers
end
Here is the client.globals.inspect:
#<Savon::GlobalOptions:0x0000000382c7a8 #options={:encoding=>"UTF-8",
:soap_version=>1, :namespaces=>{}, :logger=>#<Logger:0x0000000382c730 #progname=nil,
#level=0, #default_formatter=#<Logger::Formatter:0x0000000382c708
#datetime_format=nil>,
#formatter=nil, #logdev=#<Logger::LogDevice:0x0000000382c6b8 #shift_size=nil,
#shift_age=nil, #filename=nil, #dev=#<IO:<STDOUT>>,
#mutex=#<Logger::LogDevice::LogDeviceMutex:0x0000000382c690 #mon_owner=nil,
#mon_count=0, #mon_mutex=#<Mutex:0x0000000382c640>>>>, :log=>true, :filters=>[],
:pretty_print_xml=>false, :raise_errors=>true, :strip_namespaces=>true,
:convert_response_tags_to=>#<Proc:0x0000000382c5c8#/usr/local/rvm/gems/ruby-2.0.0-p0/gems/savon-2.1.0/lib/savon/options.rb:48 (lambda)>,
:wsdl=>"https://example.com/table.do&WSDL",
:proxy=>"http://internal.proxy.com:8080",
:basic_auth=>["user", "pass"],
:headers=>{"Authorization"=>"Basic"}}>
when i call:
client.call(:get, message: { sys_id: "67d2f77ed9377840c53fc6da9c094635" })
The service is returning:
DEBUG -- : HTTPI GET request to xseaddev.service-now.com (net_http)
INFO -- : SOAP request: https://xseaddev.service-now.com/change_task_list.do?displayvalue=all&SOAP
INFO -- : SOAPAction: "http://www.service-now.com/change_task/get", Content-Type: text/xml;charset=UTF-8, Content-Length: 408
DEBUG -- : <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://www.service-now.com" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://www.service-now.com/change_task"><env:Body><ins0:get><tns:sysId>67d2f77ed9377840c53fc6da9c094635</tns:sysId></ins0:get></env:Body></env:Envelope>
DEBUG -- : HTTPI POST request to xseaddev.service-now.com (net_http)
INFO -- : SOAP response (status 401)
Am i constructing the client incorrectly? I don't see any authentication headers being sent on either the GET or PoST requests.
Do i need to add/remove anything to get this working? Your help would be appreciated.
I imagine you should be able to do the following:
client = Savon.client(endpoint: ENDPOINT, namespace: NAMESPACE, basic_auth: ["user", "password"])
(Or the same in block form).
Check this page under the "Authentication" heading: http://savonrb.com/version2/globals.html
(I am doing the same, but with a WSDL).

API Call With Savon SOAP Client Results In ContractFilter mismatch at the EndpointDispatcher Error

I've run into an issue where the Savon Ruby Gem generates a SOAP API call that fails, however when I copy and paste the exact same XML message into SOAP-UI it succeeds.
I send this message:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tem="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vis="http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts">
<soapenv:Body>
<tem:CameraConfiguration>
<tem:request>
<vis:ClientToken>5555</vis:ClientToken>
<vis:DeviceID>26219</vis:DeviceID>
<vis:Enabled>1</vis:Enabled>
<vis:Interval>60</vis:Interval>
</tem:request>
</tem:CameraConfiguration>
</soapenv:Body>
To this API (A remote web camera configuration):
https://oapqa.onasset.com/Services/SecureOriginCommand.svc?wsdl
But it fails with this message:
SOAP response (status 500):
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode>
<faultstring xml:lang="en-US">The message with Action 'oapSetSentryReportingIntervalRequest' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)</faultstring>
</s:Fault>
</s:Body>
My first thought was that I must have made a typo in the action name. But
no, when I try the exact same message in SOAP-UI I get the following
success:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CameraConfigurationResponse xmlns="http://tempuri.org/">
<CameraConfigurationResult xmlns:a="http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Error/>
<a:Result>true</a:Result>
</CameraConfigurationResult>
</CameraConfigurationResponse>
</s:Body>
</s:Envelope>
This leads me to believe that the issue is not being caused by the format
of my xml message but with the way I'm configuring my client. Here is the actual code:
Savon.configure do |config|
config.log = :debug
config.env_namespace = :soapenv
config.raise_errors = false
end
# TODO Enable ssl certficate verification
client = Savon::Client.new do
wsdl.document = TARGET_SO_WSDL
http.auth.ssl.verify_mode = :none
end
resp = client.request 'tem', 'CameraConfiguration' do
soap.namespaces['xmlns:vis'] = 'http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts'
soap.namespaces['xmlns:tem'] = 'http://tempuri.org/'
soap.body = {
'tem:request' => {
'vis:ClientToken' => ON_ASSET_API_KEY,
'vis:DeviceID' => webcam.gps_device.device_id,
'vis:Enabled' => 1,
'vis:Interval' => webcam.report_interval
}
}
end
I've spoken to the developer who maintains the API I'm trying to
access. I thought his response could provide a clue:
Binding on the RemoteSentryService was set to mexHttpBinding instead of mexHttpsBinding.
I don’t think this should give you a fault exception, because its working on .NET simulator client I have. And this endpoint is only used to generate the wsdl (MetaExchange Binding). But, given you are using a different client, I would still give it a shot.
I also regenerated the proxy from wsdl and updated my sample simulator and it looks good.
Is this issue a known issue with Savon and Microsoft SOAP
endpoints or HTTPS? Or is this issue something only I'm encountering?
Debugged it and noticed that Savon unfortunately doesn't send the correct SOAPAction HTTP header. FYI: After sending a SOAP request via soapUI, you can click on the "RAW" tab (vertically aligned on the request window) to investigate further.
Here's the complete example:
client = Savon::Client.new do
wsdl.document = TARGET_SO_WSDL
http.auth.ssl.verify_mode = :none
end
resp = client.request 'tem', 'CameraConfiguration' do
# Notice, that the SOAPAction needs to the wrapped in double quotes:
http.headers['SOAPAction'] = %("http://tempuri.org/ISecureOriginCommand/CameraConfiguration")
soap.namespaces['xmlns:vis'] = 'http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts'
soap.body = {
'tem:request' => {
'vis:ClientToken' => 5555,
'vis:DeviceID' => 26219,
'vis:Enabled' => 1,
'vis:Interval' => 60
}
}
end
Hope it works for you!

Resources