Forum: Ruby Problem creating SOAP Request

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.
Matt S. (Guest)
on 2007-07-31 14:56
Hi there,

I am trying to do a soap request to the Mapping Service Map24.

They have a WSDL for their webservice:

http://maptp11.map24.com/map24/webservices1.5?soap...

I am attempting to do the Free Geocode operation: 'searchFree'.  It
appears this takes a RequestHeader and a MapSearchFreeRequest.  I use
the following code to create my request:

    factory =
SOAP::WSDLDriverFactory.new("http://maptp11.map24.com/map24/webservices1.5?soap...)
    driver = factory.create_rpc_driver
    result = driver.searchFree( {:Map24ID => "1"}, {:SearchText =>
"London, UK"} )

However, this only ever generates the following SOAP Request:

<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:searchFree xmlns:n1="urn:Map24Geocoder51"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <RequestHeader xsi:nil="true"></RequestHeader>
      <MapSearchFreeRequest xsi:nil="true"></MapSearchFreeRequest>
    </n1:searchFree>
  </env:Body>
</env:Envelope>

The RequestHeader and MapSearchFreeRequest parts are ALWAYS empty..?

Can anyone help?

Thanks in advance :)
dima (Guest)
on 2007-07-31 17:30
(Received via mailing list)
On Jul 31, 12:56 pm, Matt Su <removed_email_address@domain.invalid> wrote:
> the following code to create my request:
>     xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> The RequestHeader and MapSearchFreeRequest parts are ALWAYS empty..?
>
> Can anyone help?
>
> Thanks in advance :)
> --
> Posted viahttp://www.ruby-forum.com/.

You should post your question on http://groups.google.com/group/soap4r
NAKAMURA, Hiroshi (Guest)
on 2007-07-31 18:24
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Matt Su wrote:
>     factory =
> 
SOAP::WSDLDriverFactory.new("http://maptp11.map24.com/map24/webservices1.5?soap...)
>     driver = factory.create_rpc_driver
>     result = driver.searchFree( {:Map24ID => "1"}, {:SearchText =>
> "London, UK"} )

When you use a Hash as a parameter, you need to start from a parameter
name.

  result = driver.searchFree(
    {:RequestHeader => {:Map24ID => "1"}},
    {:MapSearchFreeRequest => {:SearchText => "London, UK"}}
  )

Generating stub files with wsdl2ruby.rb should be easier to use for this
kind of service which has complex request.

// NaHi

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

iQEVAwUBRq9Frh9L2jg5EEGlAQK0SAgAp19e5ag2PUflBgwqvVLtN+e7x5GHtWLl
mfI8MpaJ8P4mZ1H3hG8+SQuGzP4KoQXpcyhXrsrx77s43ozWQgj+0vhytPBo7ome
TSAA5F+HAHVTi7NSB0KNLAbrCF58MBVvJRLO8MBxm9if+IyqRGW5bP4Rt3s9Wkdg
d+Y1KoYlIUQw7S2f4Oy5g8Iaj68+L8zv2n90bFS90sz/Zoq7MtDUDPezseOnhMWC
TrdcOFTyhhXHG/z+KJbpWYDKFNsmu+x9769PdnoxBtwdTEOMiIs/oZHmNIobeCeL
dom7p/OBHgz1Gv/yZLWJrMTOBGgD7ZgGXvnGVa9efpCBRawQSZFOhg==
=K0aY
-----END PGP SIGNATURE-----
Matt S. (Guest)
on 2007-07-31 19:20
> When you use a Hash as a parameter, you need to start from a parameter
> name.
>
>   result = driver.searchFree(
>     {:RequestHeader => {:Map24ID => "1"}},
>     {:MapSearchFreeRequest => {:SearchText => "London, UK"}}
>   )
>
> Generating stub files with wsdl2ruby.rb should be easier to use for this
> kind of service which has complex request.

Thanks for your response I really appreciate it.

I tried your modification, however I still see the following SOAP
Request being generated:

<?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>
    <n1:searchFree xmlns:n1="urn:Map24Geocoder51"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <RequestHeader xsi:nil="true"></RequestHeader>
      <MapSearchFreeRequest xsi:nil="true"></MapSearchFreeRequest>
    </n1:searchFree>
  </env:Body>
</env:Envelope>

Why are the RequestHeader and MapSearchFreeRequest xsi:nil attributes
true: should they not be filled with whatever I pass in the call
driver.searchFree?

I have used the SOAP and Driver Generator before for a simpler request
for a different service and it worked perfectly.  Does the
WSDLDriverFactory and the create_rpc_driver method not always work for
complex WSDLs??

Thanks again in advance :)
NAKAMURA, Hiroshi (Guest)
on 2007-08-01 06:22
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

What version of soap4r are you using?  As Andre wrote in soap4r-ml, it
should generate request elements with earlier soap4r versions.

% ruby -rsoap/soap -e 'p SOAP::Version'

I tried soap4r-1.5.5 which is bundled with ruby-1.8.X and found that it
fails to parse the WSDL you pointed.  If you are using soap4r-1.5.5,
please update to soap4r-1.5.7 from http://dev.ctor.org/soap4r

Matt Su wrote:
>> When you use a Hash as a parameter, you need to start from a parameter
>> name.

It's wrong.  It works but not needed.  Sorry for confusing you.  The
client program you posted at first should work with soap4r-1.5.7.

Regards,
// NaHi

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

iQEVAwUBRq/uGR9L2jg5EEGlAQIeygf/ej4KhKxsZ6QXrf6X5JOsAXSxhMzuEVMS
mQ3scSskogAEPmhSrEUvr25jGJNnlkKwhd2ep/OOpD1moGEN2/x9e2Illhy9ABpk
lpqVhlggCRI4JL2N0xJBleSis4RQLXGlwO+ae3PMZ54BRcMMTYMWtcmSw81eDHEV
gqzNSUawAKnxbjF0uczHQySual2wWfMBHbM7+CPTVab99AZA3CHUgObFMcH4iOTL
Tz9cy3NF0+5+A02N1UXZ9MT70KiAYklLdsmIg5latt171Lgx3K/TzxhKegeG353U
Jmgv3SlZyo3EVYUVrC0+zmBlDUDxIlJey4MyZegB6+s/He0NUQ0Z0w==
=bwlR
-----END PGP SIGNATURE-----
This topic is locked and can not be replied to.