2017-03-06 104 views
0

我在我的Rails应用程序中使用了Savon Gem,我需要将表单域提交给Equifax。Savon SOAP请求不起作用

这里的Equifax公司XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="http://eid.equifax.com/soap/schema/canada/v3"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <v3:InitialRequest> 
     <v3:Identity> 
      <v3:Name> 
       <v3:FirstName>Michael</v3:FirstName> 
       <v3:LastName>Smith</v3:LastName> 
      </v3:Name> 
      <!--1 to 3 repetitions:--> 
      <v3:Address timeAtAddress="72" addressType="current"> 
       <v3:HybridAddress> 
        <!--1 to 6 repetitions:--> 
        <v3:AddressLine>1028 Summerville</v3:AddressLine> 
        <v3:City>Vancouver</v3:City> 
        <v3:Province>BC</v3:Province> 
        <v3:PostalCode>V7B0A8</v3:PostalCode> 
       </v3:HybridAddress> 
      </v3:Address> 
      <!--Optional:--> 
      <v3:DateOfBirth> 
       <v3:Day>26</v3:Day> 
       <v3:Month>08</v3:Month> 
       <v3:Year>1984</v3:Year> 
      </v3:DateOfBirth> 
      <v3:PhoneNumber phoneType="current"> 
       <v3:PhoneNumber>6045556666</v3:PhoneNumber> 
      </v3:PhoneNumber> 
     </v3:Identity> 
     <v3:ProcessingOptions> 
      <v3:Language>English</v3:Language> 
     </v3:ProcessingOptions> 
     </v3:InitialRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 

这是我的Ruby代码使SOAP请求。

<%= client.call(:start_transaction, message: { "v3:InitialRequest" => { "v3:Identity" => { "v3:Name" => { "v3:FirstName" => "michael", "v3:LastName" => "Smith"}, "v3:Address" => {"v3:AddressLine" => "233 Cambie St", "v3:City" => "Vancouve", "v3:Province" => "BC", "v3:PostalCode" => "V6B0E8"}, "v3:DateOfBirth" => {"v3:Day" => "26", "v3:Month" => "08", "v3:Year" => "1984"}, "v3:PhoneNumber" => {"v3:PhoneNumber" => "6048885555"}}}, attributes: { "v3:Address" => { "timeAtAddress" => "72", "addressType" => "current"}}) %> 

返回的错误消息:(肥皂:客户端)错误读取的XMLStreamReader。

有人能指出我正确的方向吗?

回答

0

请通过发送XML

xml_str = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:v3="http://eid.equifax.com/soap/schema/canada/v3"><soapenv:Header/><soapenv:Body><v3:InitialRequest><v3:Identity><v3:Name><v3:FirstName>Michael</v3:FirstName><v3:LastName>Smith</v3:LastName></v3:Name><!--1 to 3 repetitions:--><v3:Address timeAtAddress="72" addressType="current"><v3:HybridAddress><v3:AddressLine>1028 Summerville</v3:AddressLine><v3:City>Vancouver</v3:City><v3:Province>BC</v3:Province><v3:PostalCode>V7B0A8</v3:PostalCode></v3:HybridAddress></v3:Address><v3:DateOfBirth><v3:Day>26</v3:Day><v3:Month>08</v3:Month><v3:Year>1984</v3:Year></v3:DateOfBirth><v3:PhoneNumber phoneType="current"><v3:PhoneNumber>6045556666</v3:PhoneNumber></v3:PhoneNumber></v3:Identity><v3:ProcessingOptions><v3:Language>English</v3:Language></v3:ProcessingOptions></v3:InitialRequest></soapenv:Body></soapenv:Envelope>' 

client.call(:start_transaction, xml: xml_str) 

记住你可以用here document来进行的XML字符串的一个字符串尝试以下方法,但该字符串应该不是consis "\n

+0

感谢您的答复。我得到“(ns1:InvalidSecurity)处理标题时发现错误”我认为它没有使用我的wsse_auth。 client = Savon.client(wsse_auth:[“username”,“password”],wsdl:“https://ifs-uat.ca.equifax.com/uru/soap/ut/canadav3?wsdl”)%> – Michael

+0

I尝试通过soap_header传递安全性,但它也没有工作。 SOAP_HEADER = { \t \t \t \t “的wsse:安全”=> { \t \t \t \t “@soapenv:mustUnderstand属性”=> 1, \t \t \t \t “@xmlns:肥皂”=>“HTTP://模式.xmlsoap.org/wsdl/soap /“, \t \t \t \t”@xmlns:wsse“=>”http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity -secext-1.0.xsd“, \t \t \t \t”wsse:UsernameToken“=> { \t \t \t “的wsse:用户名”=> “用户名”, \t \t \t “的wsse:密码”=> “密码”, \t \t \t “消化”=>真 \t \t \t \t} \t \t \t \t} \t \t \t} – Michael