SOAP request malformed (missing n1 element)


#1

I’ve been trying to get this working for over a week now and I can’t for
the life of me work it out.

I can currently generate SOAP requests in Ruby
by two methods:

  1. Generating classes using wsdl2ruby
  2. Using SOAP4r and manually generating requests

My problem is that I can get each of these to complete 90% of the task
but
I’m unable to get either of them to complete the task 100%

Using SOAP4r I can generate a valid request:

<?xml version="1.0" encoding="us-ascii" ?>

<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
<n1:ProcessAddress xmlns:n1=“http://webservices.globaladdress.net”>
n1:usernameusername</n1:username>
n1:passwordpassword</n1:password>
n1:tmpContact
n1:AddressLine11</n1:AddressLine1>
n1:Postcodedg12 6eg</n1:Postcode>
</n1:tmpContact>
</n1:ProcessAddress>
</env:Body>
</env:Envelope>

Unfortunately it returns:

<SOAP::Mapping::Object:0x4c42486
{http://webservices.globaladdress.net}ProcessAddressResult=“true”
{http://webservices.globaladdress.net}tmpContact=#<SOAP::Mapping::Object:0x4c41536
{http://webservices.globaladdress.net}AddressLine1=“1 Murray Street”
{http://webservices.globaladdress.net}AddressLine2=“Annan”
{http://webservices.globaladdress.net}AddressLine3=“DG12 6EG”
{http://webservices.globaladdress.net}AddressLine4=“United Kingdom”
{http://webservices.globaladdress.net}AddressLine5=#SOAP::Mapping::Object:0x4c3f88a
{http://webservices.globaladdress.net}AddressLine6=#SOAP::Mapping::Object:0x4c3f4c0
{http://webservices.globaladdress.net}AddressLine7=#SOAP::Mapping::Object:0x4c3f0ec
{http://webservices.globaladdress.net}AddressLine8=#SOAP::Mapping::Object:0x4c3ed0e
{http://webservices.globaladdress.net}Company=#SOAP::Mapping::Object:0x4c3e926
{http://webservices.globaladdress.net}Building=#SOAP::Mapping::Object:0x4c3e52a
{http://webservices.globaladdress.net}SubBuilding=#SOAP::Mapping::Object:0x4c3e124
{http://webservices.globaladdress.net}Department=#SOAP::Mapping::Object:0x4c3dd1e
{http://webservices.globaladdress.net}Premise=“1”
{http://webservices.globaladdress.net}Street=“Murray Street”
{http://webservices.globaladdress.net}SubStreet=#SOAP::Mapping::Object:0x4c3b5a0
{http://webservices.globaladdress.net}POBox=#SOAP::Mapping::Object:0x4c3b168
{http://webservices.globaladdress.net}City=“Annan”
{http://webservices.globaladdress.net}SubCity=#SOAP::Mapping::Object:0x4c3a6aa
{http://webservices.globaladdress.net}Principality=#SOAP::Mapping::Object:0x4c3a254
{http://webservices.globaladdress.net}Region=“Dumfriesshire”
{http://webservices.globaladdress.net}Postcode=“DG12 6EG”
{http://webservices.globaladdress.net}DPS=#SOAP::Mapping::Object:0x4c38e0e
{http://webservices.globaladdress.net}Cedex=#SOAP::Mapping::Object:0x4c3853a
{http://webservices.globaladdress.net}Country=“United Kingdom”
{http://webservices.globaladdress.net}CountryISO=“GBR”
{http://webservices.globaladdress.net}ACR=“L5-P4S6A0T6R6Z4C4-100”>>

I haven’t been able to find a way of accessing the information inside
this
object.

If I use wsdl4rubys generated classes I generate a malformed SOAP
request:

<?xml version="1.0" encoding="us-ascii" ?>

<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
<n1:ProcessAddress xmlns:n1=“http://webservices.globaladdress.net”>
n1:usernameusername</n1:username>
n1:passwordpassword</n1:password>
n1:tmpContact
1
dg12 6eg
</n1:tmpContact>
</n1:ProcessAddress>
</env:Body>
</env:Envelope>

Note the items: addresslin1 and postcode don’t have n1 infront of them.
This causes the web service to not recognise those elements.

The response is in a format I can use. I can access each of the instance
variables.

<ProcessAddressResponse:0x984868c @processAddressResult=true,
@tmpContact=#<Contact:0x9848128 @company=nil, @region=nil,
@addressLine5=nil, @pOBox=nil, @cedex=nil, @addressLine1=“United
Kingdom”,
@department=nil, @addressLine8=nil, @principality=nil, @subStreet=nil,
@addressLine4=nil, @subBuilding=nil, @countryISO=“GBR”, @dPS=nil,
@addressLine7=nil, @subCity=nil, @street=nil,
@aCR=“L1-P0S0A0T0R0Z0C4-000”, @addressLine3=nil, @building=nil,
@postcode=nil, @addressLine6=nil, @city=nil, @premise=nil,
@country=“United Kingdom”, @addressLine2=nil>>

I’m using structs to generate the items in n1:tmpContact

address = Struct.new(:AddressLine1, :postcode)
request = Struct.new(:username, :password, :tmpContact)
driver.ProcessAddress(request.new(“username”,“password”,
address.new(“1”,
“dg12 6eg”)))

Does anyone know how I can either:

  1. Access the data in the returned object in the first example
  2. Generate a valid SOAP request with the missing n1 elements
  3. Suggest another way I can go about this