Forum: Ruby SOAP request malformed (missing n1 element)

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.
mid (Guest)
on 2007-02-01 21:16
(Received via mailing list)
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:username>username</n1:username>
      <n1:password>password</n1:password>
      <n1:tmpContact>
        <n1:AddressLine1>1</n1:AddressLine1>
        <n1:Postcode>dg12 6eg</n1:Postcode>
      </n1:tmpContact>
    </n1:ProcessAddress>
  </env:Body>
</env:Envelope>

Unfortunately it returns:

<SOAP::Mapping::Object:0x4c42486
{http://webservices.globaladdress.net}ProcessAddres...
{http://webservices.globaladdress.net}tmpContact=#<...
{http://webservices.globaladdress.net}AddressLine1="1 Murray Street"
{http://webservices.globaladdress.net}AddressLine2=...
{http://webservices.globaladdress.net}AddressLine3="DG12 6EG"
{http://webservices.globaladdress.net}AddressLine4=... Kingdom"
{http://webservices.globaladdress.net}AddressLine5=...
{http://webservices.globaladdress.net}AddressLine6=...
{http://webservices.globaladdress.net}AddressLine7=...
{http://webservices.globaladdress.net}AddressLine8=...
{http://webservices.globaladdress.net}Company=#<SOA...
{http://webservices.globaladdress.net}Building=#<SO...
{http://webservices.globaladdress.net}SubBuilding=#...
{http://webservices.globaladdress.net}Department=#<...
{http://webservices.globaladdress.net}Premise="1"
{http://webservices.globaladdress.net}Street="Murray Street"
{http://webservices.globaladdress.net}SubStreet=#<S...
{http://webservices.globaladdress.net}POBox=#<SOAP:...
{http://webservices.globaladdress.net}City="Annan"
{http://webservices.globaladdress.net}SubCity=#<SOA...
{http://webservices.globaladdress.net}Principality=...
{http://webservices.globaladdress.net}Region="Dumfr...
{http://webservices.globaladdress.net}Postcode="DG12 6EG"
{http://webservices.globaladdress.net}DPS=#<SOAP::M...
{http://webservices.globaladdress.net}Cedex=#<SOAP:...
{http://webservices.globaladdress.net}Country="United Kingdom"
{http://webservices.globaladdress.net}CountryISO="G...
{http://webservices.globaladdress.net}ACR="L5-P4S6A...

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:username>username</n1:username>
      <n1:password>password</n1:password>
      <n1:tmpContact>
        <addressline1>1</addressline1>
        <postcode>dg12 6eg</postcode>
      </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
This topic is locked and can not be replied to.