soapUI から生成された次の WSDL があります。soapUI からのリクエストをテストすると、正常に動作しますが、savon から例外がスローされます。Linux で savon 0.9.2 を使用しています。
<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>
エラーを引き起こすスクリプト:
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
出力:
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"}}
SoapUI からの出力は次のとおりです。
<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>