Problem creating SOAP Request

Hi there,

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

They have a WSDL for their webservice:

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=Map24Geocoder51")
    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 :slight_smile:

···

--
Posted via http://www.ruby-forum.com/.

You should post your question on http://groups.google.com/group/soap4r

···

On Jul 31, 12:56 pm, Matt Su <matthewjsumm...@googlemail.com> wrote:

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=Map24Geocoder51

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=Map24Geocoder51&quot;\)
    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&quot;
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/&quot;
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
  <env:Body>
    <n1:searchFree xmlns:n1="urn:Map24Geocoder51"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/&quot;&gt;
      <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 :slight_smile:
--
Posted viahttp://www.ruby-forum.com/.

Hi,

Matt Su wrote:

    factory =
SOAP::WSDLDriverFactory.new("http://maptp11.map24.com/map24/webservices1.5?soap=Map24Geocoder51&quot;\)
    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

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&quot;
    xmlns:env="Error;
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
  <env:Body>
    <n1:searchFree xmlns:n1="urn:Map24Geocoder51"
        env:encodingStyle="Error;
      <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 :slight_smile:

···

--
Posted via http://www.ruby-forum.com/\.

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