2013-05-20 2 views
0

Мне предоставлен API-интерфейс службы wsdl, я никогда не делал этого и не уверен, что мне с ним делать.Прочитайте содержимое SOAP с помощью описания WSDL

Файл является описание того, что они собираются отправить нам:

<?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> 

И до сих пор, я следующий код, который не работает:

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 

ответ

0

Я обычно просто шип из реализация, чтобы увидеть, какие значения типов возвращаются путем печати возвращаемых значений #body и #hash.

Указанные примеры в Savon documentation:

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

Или использовать что-то вроде awesome_print, чтобы увидеть точную структуру данных в теле ответа.

+0

Дело в том, что мы предоставили структуру xml-файла, и они отправят нам xml-флаги (мы не запрашиваем). поэтому мы на самом деле не запрашиваем их, но ожидаем их запроса. (с файлом xml они описывают, что их данные будут выглядеть) – phil88530

+0

Я не уверен, что полностью понимаю. Ваше приложение принимает запросы от другого клиента? Разве это не означает, что вы на самом деле создаете сервер? Если да, то часть о клиенте, дающая вам файл WSDL, действительно не подходит. – veidt

Смежные вопросы