0

I've been given a service API of wsdl, I've never done it and not sure what I should do with it.

The file is a description of what they gonna send us:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://moneysupermarket.com/callback" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://moneysupermarket.com/callback" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://moneysupermarket.com/callback">
            <s:element name="SendRequestCallBack">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="requestCallBack" type="tns:RequestCallBack" />
                    </s:sequence>
                </s:complexType>
            </s:element>
            <s:complexType name="RequestCallBack">
                <s:sequence>
                    <s:element minOccurs="0" maxOccurs="1" name="QuoteId" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" name="PhoneNumber" type="s:string" />
                    <s:element minOccurs="1" maxOccurs="1" name="CallTime" nillable="true" type="s:dateTime" />
                </s:sequence>
            </s:complexType>
        </s:schema>
    </wsdl:types>
    <wsdl:message name="SendRequestCallBackSoapIn">
        <wsdl:part name="parameters" element="tns:SendRequestCallBack" />
    </wsdl:message>
    <wsdl:portType name="ServiceSoap">
        <wsdl:operation name="SendRequestCallBack">
            <wsdl:input message="tns:SendRequestCallBackSoapIn" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="SendRequestCallBack">
            <soap:operation soapAction="http://moneysupermarket.com/callback/SendRequestCallBack" style="document" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="SendRequestCallBack">
            <soap12:operation soapAction="http://moneysupermarket.com/callback/SendRequestCallBack" style="document" />
            <wsdl:input>
                <soap12:body use="literal" />
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
</wsdl:definitions>

And so far, I have the following code that doesn't work:

class PhonebackRequest < ActiveRecord::Base
    attr_reader :callTime, :phoneNumber, :quoteId

    validates_presence_of :phoneNumber, :quoteId


    def self.retrive_new_requests
        # create a client for the service
        client = Savon::Client.new File.path(Rails.public_path+"/moneysupermarket/Service.xml")

        response = client.request(:wsdl, "send_request_call_back"){soap.body = { :requestCallBack => 'true' }}

    #not sure what goes next

    end

end
phil88530
  • 1,499
  • 3
  • 19
  • 27

1 Answers1

0

I usually just spike out an implementation to see what type values get returned by printing the return values of #body and #hash.

Given examples in the Savon documentation:

response.body[:response][:success] #=> true
response.body[:response][:name]    #=> "luke"

Or use something like awesome_print to see the exact data structure in the response body.

James
  • 4,599
  • 2
  • 19
  • 27
  • The thing is, we been give the structure xml file, and they will send us xml flags(we aren't requesting). so we aren't actually requesting, but waiting for them request us.(with the xml file they describe that their data will be look like) – phil88530 May 20 '13 at 12:40
  • I'm not sure I completely understand. Your application is accepting requests from another client? Doesn't this mean you're actually creating a server? If so, then the part about the client giving you a WSDL file doesn't really fit. – James May 20 '13 at 16:28