Topic: Consume webservice

I'm trying consume this webservice, but i have no idea how i can do that..

http://www.bronzebusiness.com.br/webservices/wscep.asmx

I already search for some topics using soap4r, savon (i cant install, always return error when i try install gem)

I'm using rails 3.0.9.

For test this webservice, can use this input parameter: 83321230

It is a postal code from brazilian streets

Last edited by markd2lp (2011-09-06 09:49:36)

Re: Consume webservice

def busca_cep
    require 'soap/rpc/driver'

    XSD::Charset.encoding = 'UTF8'
    
    wsdl = 'http://www.bronzebusiness.com.br/webservices/wscep.asmx?wsdl'
    namespace = 'http://tempuri.org/'
    webmethod = "cep"
    
    soapoperation = namespace + webmethod
    param1 = "strcep"

    #Initializing the SOAP RPC driver using the WSDL
    driver = SOAP::RPC::Driver.new(wsdl, namespace)
    #Setting the encoding style to ASPDotNetHandler encoding style. Failing to do so will return null username and password in the web service.
    driver.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
    #Initialize the handler for web method in the client
    driver.add_method_with_soapaction(webmethod, soapoperation, param1)
    #Setting the driver to dump debug information to the console
    driver.wiredump_dev = STDERR
    #Invoke the web method and retrieve the return value
    result = driver.cep("#{params[:id]}")   
     
    
    if(result.nil?)
      render :json => { :success => false }
    else
      render :json => { :success => true }
    end
  end

This code are not working,

undefined method `name=' for #<XSD::QName:0x..fdb764958 {}item>

Last edited by markd2lp (2011-09-06 10:32:16)