Forum: Ruby on Rails SOAP Question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
88090efa947b717fac09706c16f3620a?d=identicon&s=25 John Faltys (Guest)
on 2006-12-24 06:18

Have have API documentation that looks like this

The API uses HTTP(S) as the transport mechanism and connects to the
normal web port (80). It can be accessed in two ways; bare-bone HTTP
requests where URL’s uniquely identifies the request, and SOAP where a
single URI is used but the request itself is encoded with XML.

formputxml
REQUEST:
  /formputxml
PARAM:
  xmldoc   = "an XML document of Configuration, Directory or Command"
It posts a Configuration or Command document to set the configurations
or issue a command. Like getxml, it has the data URL form-data encoded
with one single parameter. The Content-Type of the document must be of
type “application/x-www-form-urlencoded” and the body must be encoded
accordingly (e.g. first line will be xmldoc=<then the document>).

putxml
REQUEST:
  /putxml
PARAM:
  HTTP BODY as argument
Putxml is like "formputxml", put uses the complete BODY as argument
(i.e. the content of the xmldoc parameter). The Content-type should be
"text/xml" or "application/xml" ( or "text/plain"), though no check at
the moment. (Except for application/x-www-form-urlencoded which will
cause a failure).


Here is my test function to try and send some xml to the api.

    strUser = 'admin'
    strPWD = 'password'
    strServer = 'http://192.168.0.248/'
    strURI = 'command.xml'
    strRequest = %{
          <Command>
            <Dial item="1">
              <Number item="1">9991112222</Number>
            </Dial>
          </Command>
    }


    driver = SOAP::RPC::Driver.new(strServer)
    driver.wiredump_dev = STDERR
    driver.options["protocol.http.basic_auth"] << [strServer, strUser,
strPWD]

    driver.add_method('putxml','request')
    page.alert driver.putxml(strRequest)
Here is what I see in the command window
! CONNECTION ESTABLISHED
POST / HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
Authorization: Basic YWRtaW46VEFOREJFUkcx
User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.4 (2005-12-24)
[i686-darwin8.5.2])
Date: Sat Dec 23 17:15:32 PST 2006
Content-Length: 600
Host: 192.168.0.248

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <putxml
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <request xsi:type="xsd:string">
          &lt;Command&gt;
            &lt;Dial item=&quot;1&quot;&gt;
              &lt;Number item=&quot;1&quot;&gt;9991112222&lt;/Number&gt;
            &lt;/Dial&gt;
          &lt;/Command&gt;
    </request>
    </putxml>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 404 Not Found

It looks like I am creating the xml incorrectly, and calling the api
incorrectly.
This topic is locked and can not be replied to.