首页 > 解决方案 > 从 Rails 发出 SOAP/XML 请求

问题描述

我有一个 xml 对象xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header/>
        <soapenv:Body>
            <GetLocations xmlns="http://clients.mindbodyonline.com/api/0_5_1">
                <Request>
                <SourceCredentials>
                    <SourceName>{SourceName}</SourceName>
                    <Password>{Password}</Password>
                    <SiteIDs>
                        <int>{SiteID}</int>
                    </SiteIDs>
                </SourceCredentials>
                <XMLDetail>Bare</XMLDetail>
                <PageSize>10</PageSize>
                <CurrentPageIndex>0</CurrentPageIndex>
                <Fields>
                    <string>Locations.Name</string>
                    <string>Locations.City</string>
                </Fields>
                </Request>
            </GetLocations>
        </soapenv:Body>
    </soapenv:Envelope>

并试图复制我在示例中找到的这个请求:

POST https://clients.mindbodyonline.com/api/0_5_1/SiteService.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://clients.mindbodyonline.com/api/0_5_1/GetLocations"
Host: clients.mindbodyonline.com
Content-Length: 795

但我不知道如何SOAPAction在我的请求中使用类似RestClient.

您如何包含此类参数,或者是否有不同的方式来发出此类请求?

标签: ruby-on-railssoaprest-client

解决方案


在此处查看他们用 ruby​​ 编写的示例代码。

您可以使用savon gem 来执行请求,您可以查看显示如何执行此操作的代码示例。


推荐阅读