Savon create matched XML pattern

本小妞迷上赌 提交于 2020-01-17 08:15:12

问题


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.


回答1:


You should set the correct env_namespace :

Savon.client(env_namespace: :soapenv)

Ctrl+F for env_namespace here



来源:https://stackoverflow.com/questions/18568031/savon-create-matched-xml-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!