NAKAMURA, Hiroshi
11/11/2003 2:17:00 AM
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:
>
> <complexType name="Channel">
> <xsd:sequence>
> <xsd:element name="code" type="xsd:string" nillable="false"/>
> <xsd:element name="name" type="xsd:string" nillable="false"/>
> <xsd:element name="category" type="xsd:string" nillable="false"/>
> </xsd:sequence>
> </complexType>
> <complexType name="ChannelList">
> <sequence>
> <element maxOccurs="unbounded" minOccurs="0" name="Channel"
> type="epg:Channel"/>
> </sequence>
> </complexType>
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