# SOAP Request Problem

**URL:** <https://www.ruby-forum.com/t/soap-request-problem/86580>\
**Category:** Ruby\
**Created:** [February 23, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/soap-request-problem/86580 "2007-02-23T13:35:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mid](https://www.ruby-forum.com/u/mid)\
**Post date:** [February 23, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/soap-request-problem/86580/1 "2007-02-23T13:35:35Z")

</div>

I’ve posted about this before but so far I’ve had no response. Since  
then  
I’ve also been to #Ruby and #rubyonrails on Freenode but still nothing  
so  
I thought I’d post one last time.

===================

I’m trying to use a web service and I have found two ways to go about  
it.

# Option 1

I use SOAP4r and I get a response from the service but in a format I’m  
unable to extract data from:

E.g.

\<SOAP::Mapping:bject:0x4c42486  
{[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}ProcessAddressResult=“true”  
{[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}  
tmpContact=#\<SOAP::Mapping:bject:0x4c41536  
{[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine1=“1 Murray Street”  
{[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine2=“Annan”  
{[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine3=“DG12 6EG”  
{[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine4=“United Kingdom”  
etc…

For instance, I don’t know how I can access AddressLine3. If I could do  
that then this problem is solved.

# Option 2

I use wsdl2ruby. This method returns data in a format I can use. I can  
access elements by using something like response.AddressLine3 etc.

Unfortunately, using wsdl2ruby, I can’t seem to create the correct XML  
elements.

E.g. When I specify addressline1 and postcode they don’t appear as  
n1:addressline1 and n1:postcode

n1:usernameusername\</n1:username\>  
n1:passwordpassword\</n1:password\>  
n1:tmpContact  
1  
dg12 6eg  
\</n1:tmpContact\>

If I could specify these elements with n1: infront of them then this is  
another solution that would work but so far I can’t do either.

---

<div class="post-metadata">

**Author:** ![mid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mid](https://www.ruby-forum.com/u/mid)\
**Post date:** [February 23, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/soap-request-problem/86580/2 "2007-02-23T20:22:47Z")

</div>

On 2/23/07, mid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> […]

I once had a similar issue where the SOAP request generated from my  
wsdl2ruby client didn’t have proper namespaces specified. My mistake  
at that time was passing a Hash or a String instead of the correct  
object to the method:

#!/usr/bin/env ruby  
require ‘UserInfoDriver.rb’

soap = UserInfoSoap.new(endpoint\_url)

# run ruby with -d to see SOAP wiredumps.

soap.wiredump\_dev = STDERR if $DEBUG

# SYNOPSIS

# GetUserByUsername(parameters)

# 

# ARGS

# parameters GetUserByUsername

# - {urn:::Users}GetUserByUsername

# 

# RETURNS

# parameters GetUserByUsernameResponse

# - {urn:::Users}GetUserByUsernameResponse

# 

parameters = “lapidary”  
p soap.getUserByUsername(parameters) # =\> doesn’t work

parameters = GetUserByUsername.new(“lapidary”)  
p soap.getUserByUsername(parameters) # =\> does work

---

<div class="post-metadata">

**Author:** ![mid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mid](https://www.ruby-forum.com/u/mid)\
**Post date:** [June 6, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/soap-request-problem/86580/3 "2007-06-06T16:11:28Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi,

Sorry for the late response.

mid wrote:

> {[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}ProcessAddressResult=“true”  
> {[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}  
> tmpContact=#\<SOAP::Mapping:bject:0x4c41536  
> {[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine1=“1 Murray Street”  
> {[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine2=“Annan”  
> {[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine3=“DG12 6EG”  
> {[http://webservices.globaladdress.net](http://webservices.globaladdress.net)}AddressLine4=“United Kingdom” etc…
> 
> For instance, I don’t know how I can access AddressLine3. If I could do  
> that then this problem is solved.

obj.tmpContact.addressLine3  
obj[“tmpContact”][“AddressLine3”]

Both should work.

> n1:usernameusername\</n1:username\>  
> n1:passwordpassword\</n1:password\>  
> n1:tmpContact  
> 1  
> dg12 6eg  
> \</n1:tmpContact\>

Can you try soap4r-1.5.6 RC2 ? You can download RC2 from  
[http://dev.ctor.org/soap4r/wiki#a2007-06-05:1.5.6-RC2](http://dev.ctor.org/soap4r/wiki#a2007-06-05:1.5.6-RC2)  
And can you send me the WSDL you are using? I’ll check it and see  
what’s wrong with it.

Regards,  
// NaHi

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.5 (Cygwin)

iQEVAwUBRmbAVh9L2jg5EEGlAQJ0agf/Uyqu8+xIoimB7AmsWZ4ln3SLVsNfl9d6  
0Tw5jnISzsK88YsKo3YJL15PTMlwPSbXgezjSbFhNNeQcovoET8S93+kDsYLV8cK  
RGD6J6tVlm4KPqOFRrmvI7BXuZiZYcbYSd1EDabFd4jjDavFnVJ/dIzQOUO2xdB5  
dpQsryHfJSXfvqacbPS0jFVeVZKqUmAEAFy2kslR3bJ+V7yP+CnzPNnpfcwws+cY  
q6NFICZAaQWf3s0vFS0x4fhp9l69pBhOGCmYM90rPZP/GY21bn/ocISaRlTk7+8Y  
LhFw72rN4HC4aV0x2YLHH9YjqDSzsE22+x17dvVgtLL7X0dbTUFUhw==  
=j2jt  
-----END PGP SIGNATURE-----
