SOAP4r sequences and authentication

Hi,

I’ve been asked to generate a SOAP client for a J2EE project. I’ve been
given a wsdl file and running wsdl2ruby on it generates a working client.

The problem I’m having is in retrieving multiple items from the server.
The wsdl file contains the following:

and wsdl2ruby generates these classes:

class Channel
@@schema_type = “Channel”
@@schema_ns = “http://test.com.au

def code
@code
end

def code=(value)
@code = value
end

def name
@name
end

def name=(value)
@name = value
end

def category
@category
end

def category=(value)
@category = value
end

def initialize(code = nil,
name = nil,
category = nil)
@code = code
@name = name
@category = category
end
end

class ChannelList
@@schema_type = “ChannelList”
@@schema_ns = “http://test.com.au

def Channel
@channel
end

def Channel=(value)
@channel = value
end

def initialize(channel = nil)
@channel = channel
end
end

When I run the generated client.rb file and call listAllChannels, which is
supposed to return a ChannelList containg a number of channels, only one
channel is returned. I assume that this is due to the ChannelList class
only holding one Channel.

Is there a way of generating a client that returns an array of channels
using wsdl2ruby.rb from the wsdl file shown above?

I’ve had a brief look at some of the SOAP spec and it looks like using
SOAP-ENC:Array for the ChannelList may have been a better description of
the data but I’m not in a position to change that.

On a related issue how would I go about passing authentication data
username and password with a SOAP request?

TIA,

Martin

Hi,

From: “Martin Stannard” martins@aardvark.net.au
Sent: Tuesday, November 11, 2003 7:59 AM

I’ve been asked to generate a SOAP client for a J2EE project. I’ve been
given a wsdl file and running wsdl2ruby on it generates a working client.

The problem I’m having is in retrieving multiple items from the server.
The wsdl file contains the following:

Hmm. It seems that the wsdl uses for literal encoding(no encoding).
Can I see entire definition of the wsdl?

Wsdl2ruby.rb only supports SOAP Encoding now… With SOAP Encoding,
WSDL should be like this;

  <xsd:complexType name="MyStruct">
    <xsd:sequence>
      <xsd:element name="boolean" type="xsd:boolean"/>
      <xsd:element name="int" type="xsd:int"/>
      <xsd:element name="double" type="xsd:double"/>
      <xsd:element name="string" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="MyStructArray">
    <xsd:complexContent>
      <xsd:restriction base="soapenc:Array">
         <xsd:attribute ref="soapenc:arrayType"
             wsdl:arrayType="typens:MyStruct[]"/>
      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>

To access literal encoding SOAP service, without WSDL,
soap4r/sample/soap/icd/* may help you. In short example,
following should work.

require 'soap/rpc/driver’
server = ARGV.shift
drv = SOAP::RPC::Driver.new(server, “urn:serviceNamespace”)

This line is for literal encoding -> language mapping which has

its origin in ASP.NET.

drv.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
drv.add_method(“getChannelList”)

drv.getChannedList.Channel.each do |ch|
p ch
end

Is there a way of generating a client that returns an array of channels
using wsdl2ruby.rb from the wsdl file shown above?

Using wsdl2ruby.rb is a must?

On a related issue how would I go about passing authentication data
username and password with a SOAP request?

With SOAP Header, not embedding auth data into SOAP Body?
There is very low level API for now… An example is in
soap4r/sample/soapbox/* but I must add high level API and examples
for it.

Regards,
// NaHi