Simple Savon SOAP request not working - ruby

I have the following WSDL, generated from soapUI. When I test the
request from soapUI, it works fine but throws exception from savon.
I am using savon 0.9.2 on Linux.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:mes="http://www.domain.com/sub/05/00/Messages">
<soapenv:Header/>
<soapenv:Body>
<mes:loginRequest>
<!--Optional:-->
<mes:Username>admin</mes:Username>
<!--Optional:-->
<mes:Password>pass</mes:Password>
<!--Optional:-->
<mes:ImpersonationUsername></mes:ImpersonationUsername>
<!--Optional:-->
<mes:ApplicationName></mes:ApplicationName>
</mes:loginRequest>
</soapenv:Body>
</soapenv:Envelope>
The script, which causes Errors:
require 'rubygems'
require 'savon'
require 'pp'
client = Savon::Client.new "http://domain/Service.asmx?WSDL"
response = client.request(:mes, "login") do
soap.body = {
"mes:Username" => "test",
"mes:Password" => "test",
"mes:ImpersonationUsername"=>"Test",
"mes:ApplicationName"=>"test"
}
end
pp response.to_hash
The Output:
D, [2011-05-10T16:06:14.316827 #11254] DEBUG -- : <?xml version="1.0"
encoding="utf-8"?><soap:Envelope xmlns:soap="http://
schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/
XMLSchema"><soap:Body><LoginResult xmlns="http://www.domain.com/sub/
05/00/
Messages"><ErrorDetails><Items><SfExceptionItem><ExceptionType>System.NullReferenceException</
ExceptionType><AssemblyName>mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b73a5c561934e089</
AssemblyName><Message>Object reference not set to an instance of an
object.</Message></SfExceptionItem></Items><FaultCode>UnknownError</
FaultCode><Message>Object reference not set to an instance of an
object.</Message></ErrorDetails></LoginResult></soap:Body></
soap:Envelope>
{:login_result=>
{:error_details=>
{:items=>
{:sf_exception_item=>
{:message=>"Object reference not set to an instance of an
object.",
:exception_type=>"System.NullReferenceException",
:assembly_name=>
"mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b73a5c561934e089"}},
:message=>"Object reference not set to an instance of an
object.",
:fault_code=>"UnknownError"},
:xmlns=>
"http://www.domain.com/sub/05/00/Messages"}}
The output from SoapUI is the following:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResult xmlns="http://domain/sub/05/00/Messages">
<UserTicket>95bfaa81149f4c118c8724b837235cd5</UserTicket>
</LoginResult>
</soap:Body>
</soap:Envelope>

You might want to set the namespace in your savon request: client.namespaces["xmlns:mes"] = "http://www.domain.com/sub/05/00/Messages"

the request you send creates the following soap message
<?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:mes="urn:namespace.com"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<mes:login>
<mes:Username>test</mes:Username>
<mes:Password>test</mes:Password>
<mes:ImpersonationUsername>Test</mes:ImpersonationUsername>
<mes:ApplicationName>test</mes:ApplicationName>
</mes:login>
</env:Body>
I guess that's not what your intention is?
please insert the following lines into your code after the .new
Savon.configure do |c|
c.log = true
end
that shows the outgoing message.

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>

Savon create matched XML pattern

I am trying to get the pan info from the income tax of india web API.
The standard XML for the request is this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:pan="http://panws.dit.tcs.com/" xmlns:typ="http://panws.dit.tcs.com/types/">
<soapenv:Header/>
<soapenv:Body>
<pan:getPanInfo>
<login>
<typ:userName>xxxxxxxxx</typ:userName>
<typ:password>xxxxxxxxxx</typ:password>
</login>
<panNo>
<typ:panNo>xxxxxxxxxxxxx</typ:panNo>
</panNo>
</pan:getPanInfo>
</soapenv:Body>
</soapenv:Envelope>
I am using SAVON ruby gem to submit the request in the above format. My code is
client = Savon.client do |globals|
globals.wsdl 'https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/PanWS.wsdl'
end
client.call(:get_pan_info, message: {
"login" => {
"typ:userName" => "xxxxxxxxxx",
"typ:password" => "xxxxxxxxxxxxxxxx"
},
"panNo" => {
"typ:panNo" => "xxxxxxxxxxxxxxx"
}
})
It creates the XML to be submitted is here:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://panws.dit.tcs.com/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://panws.dit.tcs.com/types/">
<env:Body>
<tns:getPanInfo>
<tns:login>
<typ:userName>xxxxxxx</typ:userName>
<typ:password>xxxxxxxxxxxx</typ:password>
</tns:login>
<tns:panNo>
<typ:panNo>xxxxxxxxxxxxxx</typ:panNo>
</tns:panNo>
</tns:getPanInfo>
</env:Body>
</env:Envelope>
and it gives 500 External server Error,
Can any body please point me out where i am wrong or how to create the same XML for the request.
You should set the correct env_namespace :
Savon.client(env_namespace: :soapenv)
Ctrl+F for env_namespace here

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

How to create urn:localhost-catalog SOAP header in Ruby?

I have this (working) example in php:
$usernameToken = new SoapHeaderUsernameToken( $password, $username );
$soapHeaders[] = new SoapHeader("urn:localhost-catalog", 'UsernameToken', $usernameToken);
$client = new SoapClient("my_client_url");
$client->__setSoapHeaders( $soapHeaders );
But I want a client in Ruby. I'm using the savon gem, which can do authentication for you. So far, I have the following method:
def my_soap_client
client = Savon::Client.new do
wsdl.document = "my_client_url"
end
client.wsse.credentials "usr", "pass" # Adding :digest doesn't seem to help
return client
end
# I make requests like this:
my_soap_client.request :wsdl, "getProductGroups", :parent_id => 1
I can successfully list available actions, but if I try to make a request, the result is always "(SOAP-ENV:Client) Missing parameter". Also, it doesn't matter if I pass correct credentials or fake ones. That is why I believe the authentication fails.
Hope someone can help!
Using Wireshark sniffer I intercepted SOAP request that your PHP code sends. It looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:examples:helloservice"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="urn:localhost-catalog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns2:UsernameToken>
<Password>pass</Password>
<Username>login</Username>
</ns2:UsernameToken>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:getProductGroups>
<parentId>1</parentId>
</ns1:getProductGroups>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Here you can see that this code adds ns2 namespace for UsernameToken header.
Then I intercepted SOAP request that sends your Ruby code:
<?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://www.ecerami.com/wsdl/HelloService.wsdl"
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 wsu:Id="UsernameToken-1"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>usr</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
pass
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<wsdl:getProductGroups>
<parentId>1</parentId>
</wsdl:getProductGroups>
</env:Body>
</env:Envelope>
You can see the difference - UsernameToken is wrapped into Security element and namespace for UsernameToken is "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
Your PHP code uses custom authorization and savon does not support it via wsse property. I looked into Savon source code, it uses Akami.wsse and in its code there is no possibility to set namespace. This means you need to manually construct headers. Here is the code in Ruby that generates SOAP request like you possibly need:
require 'savon'
client = Savon::Client.new do
wsdl.document = "test.wsdl"
end
client.request :wsdl, "sayHello" do
soap.namespaces["xmlns:ns2"] = "urn:localhost-catalog"
soap.header = { "ns2:UsernameToken" =>
{"Password" => "pass", "Username" => "login"}
}
soap.body = { :parent_id => 1 }
end
It generate the following SOAP request:
<?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://www.ecerami.com/wsdl/HelloService.wsdl"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns2="urn:localhost-catalog">
<env:Header>
<ns2:UsernameToken>
<Password>pass</Password>
<Username>login</Username>
</ns2:UsernameToken>
</env:Header>
<env:Body>
<wsdl:sayHello>
<parentId>1</parentId>
</wsdl:sayHello>
</env:Body>
</env:Envelope>
Hope this helps!
to set a header in Savon use the following expression:
client.request :wsdl, "getProductGroups" do
soap.header = { :header_key => "your header goes here",
:attributes! => { :attr => "your attribute" }
}
soap.body = { :parent_id => 1 }
end
perhaps that helps you.
-st

Ruby - Savon web services authentication

I'm attempting to utilize the ruby gem Savon to connect to a web service provided by propertyware (http://propertyware.com/apidocs/Getting-Started). I've successfully connected to the service via SoapUI and executed an echoString request. When I try to do the same via Ruby I get a null user authentication error.
Here's what I've tried in Ruby...
require 'rubygems'
require 'savon'
client = Savon::Client.new do
wsdl.document = 'http://propertyware.com/pw/services/PWServices?wsdl'
wsse.credentials 'username', 'pwd'
end
response = client.request :web, :echo_string, :body => {:arg => "Hello world."}
Which produces the following xml...
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://propertyware.com/pw/services/PWServices"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ins0="http://propertyware.com/pw/services/PWServices"
xmlns:ins1="http://criteria.soap.propertyware.com"
xmlns:ins2="urn:PWServices"
xmlns:ins3="http://soap.propertyware.com"
xmlns:ins4="http://xml.apache.org/xml-soap">
<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>user</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pwd</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<web:echoString>
<arg>Hello world.</arg>
</web:echoString>
</env:Body>
</env:Envelope>
Here's the xml produced by SoapUI...
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="http://webservices" >
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>user</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pwd</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">R41mCRd+tY+xthhE/YISLQ==</wsse:Nonce>
<wsu:Created>2011-10-25T09:52:40.220Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<web:echoString soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<arg xsi:type="xsd:string">?</arg>
</web:echoString>
</soapenv:Body>
</soapenv:Envelope>
One obvious difference is that SoapUI includes a nonce key and a createdAt timestamp. I'm not sure how to make savon do that without moving to digest auth. (and fwiw that doesn't work).
I'm not real savoy in the ways of web services - any guidance would be much appreciated.
Also - here's the response when I attempt to connect via savon:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.Unauthenticated</faultcode>
<faultstring>User 'null' not authenticated (unknown user)</faultstring>
<detail>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">rcpppwwwapt012.realpage.com</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
TIA!
Bob
Try setting the digest in the wsse to true. This will instruct Savon to add the nonce and createdAt to the request:
wsse.credentials 'username', 'pwd', :digest
See the comments of this object for more info
In Savon version 2 you need following:
client = Savon.client do
wsdl 'https://webservice/theservice.wsdl'
wsse_auth("user", "pass", :digest)
end
I believe the first step would be to deal with the error.
<faultstring>User 'null' not authenticated (unknown user)</faultstring>
Your credentials aren't being passed to the service.

Resources