# Ruby and Soap Soap4r

**URL:** <https://www.ruby-forum.com/t/ruby-and-soap-soap4r/154848>\
**Category:** Rails\
**Created:** [December 4, 2008, 1:33pm UTC](https://www.ruby-forum.com/t/ruby-and-soap-soap4r/154848 "2008-12-04T13:33:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![noisewaterphd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@noisewaterphd](https://www.ruby-forum.com/u/noisewaterphd)\
**Post date:** [December 4, 2008, 1:33pm UTC](https://www.ruby-forum.com/t/ruby-and-soap-soap4r/154848/1 "2008-12-04T13:33:26Z")

</div>

I can’t wrap my head around a soap4r issue i’m having, need some help  
please!

So here is what I have:

This is the example envelope from a .net web service to authorize:

POST /PublicAPIReport/publicapiservice.asmx HTTP/1.1  
Host: 10.1.2.64  
Content-Type: text/xml; charset=utf-8  
Content-Length: length  
SOAPAction: “[http://REMOVEDFORSECURITY/WebServices/PublicAPIService/](http://REMOVEDFORSECURITY/WebServices/PublicAPIService/)  
Authorize”

\<?xml version="1.0" encoding="utf-8"?\>

\<soap:Envelope xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”  
xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)” xmlns:soap=“http://  
[schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”\>  
soap:Body  
  
  
string  
string  
string  
string  
  
  
\</soap:Body\>  
\</soap:Envelope\>

Here is my code to create this envelope:

def store\_metric

```
endpoint_url = "http://REMOVEDFORSECURITY/PublicAPIReport/

```

publicapiservice.asmx"  
namespace = “[http://REMOVEDFORSECURITY/WebServices/](http://REMOVEDFORSECURITY/WebServices/)  
PublicAPIService”  
soapaction = “[http://REMOVEDFORSECURITY/WebServices/](http://REMOVEDFORSECURITY/WebServices/)  
PublicAPIService/Authorize”  
user = “REMOVEDFORSECURITY”  
pass = “REMOVEDFORSECURITY”  
company = “REMOVEDFORSECURITY”  
version = “7.0.1”

```
driver = SOAP::RPC::Driver.new(endpoint_url, namespace,

```

soapaction)  
driver.add\_rpc\_method(‘Authorize’, ‘User’ , ‘Password’,  
‘CompanyID’ , ‘Version’)  
authorize = driver.Authorize(user, pass, company , version)

end

But this code of course results in this:

Wire dump:

= Request

! CONNECT TO 10.1.2.64:80  
! CONNECTION ESTABLISHED  
POST /PublicAPIReport/publicapiservice.asmx HTTP/1.1  
SOAPAction: “[http://REMOVEDFORSECURITY/WebServices/PublicAPIService/](http://REMOVEDFORSECURITY/WebServices/PublicAPIService/)  
Authorize”  
Content-Type: text/xml; charset=utf-8  
User-Agent: SOAP4R/1.5.5 (/187, ruby 1.8.6 (2007-03-13) [powerpc-  
darwin8.8.0])  
Date: Thu, 04 Dec 2008 10:44:16 GMT  
Content-Length: 640  
Host: 10.1.2.64

\<?xml version="1.0" encoding="utf-8" ?\>

\<env:Envelope xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”  
xmlns:env=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”\>  
env:Body  
\<n1:Authorize xmlns:n1=“[http://REMOVEDFORSECURITY/WebServices/](http://REMOVEDFORSECURITY/WebServices/)  
PublicAPIService”  
env:encodingStyle=“[http://schemas.xmlsoap.org/soap/encoding/](http://schemas.xmlsoap.org/soap/encoding/)”\>  
REMOVEDFORSECURITY  
REMOVEDFORSECURITY  
Uinta  
7.0.1  
\</n1:Authorize\>  
\</env:Body\>  
\</env:Envelope\>

= Response

HTTP/1.1 200 OK  
Date: Thu, 04 Dec 2008 10:44:16 GMT  
Server: Microsoft-IIS/6.0  
X-Powered-By: [ASP.NET](http://ASP.NET)  
X-AspNet-Version: 2.0.50727  
Cache-Control: private, max-age=0  
Content-Type: text/xml; charset=utf-8  
Content-Length: 388

\<?xml version="1.0" encoding="utf-8"?\>\<soap:Envelope

xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”  
xmlns:xsd=“[http://www.w3.org/2001/](http://www.w3.org/2001/)  
XMLSchema”\>soap:Bodyfalse\</  
AuthorizeResponse\>\</soap:Body\>\</soap:Envelope\>

Thanks so much for any help! I’m pulling my hair out trying to figure  
out how to get it working.

-Cam
