从Rails发出SOAP / XML请求

时间:2018-12-18 16:43:21

标签: ruby-on-rails soap rest-client

我有一个xml对象function logBeforeCall1() { return function ( this: any, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor, ): PropertyDescriptor { const originalMethod = descriptor.value; descriptor.value = (...args: any[]) => { console.log('hello!'); return originalMethod.apply(this, args); }; return descriptor; }; }

xml

并且正在尝试复制我found in an example的请求:

<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之类的内容。

您如何包含此类参数,或者有其他方法发出这种类型的请求?

1 个答案:

答案 0 :(得分:0)

查看他们用ruby here编写的示例代码。

您可以使用savon gem来执行请求,您可以查看此code示例,该示例演示了如何执行此操作。