Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resolving [XMLAttribut] in Delphi

20 views
Skip to first unread message

CheGueVerra

unread,
Aug 28, 2008, 5:40:57 PM8/28/08
to
Hi All,

I created a simple WebService (.NET) that returns a List<Foo>. The
Foo class has this declaration in it:

public class Foo
{
public Foo() {}

[XmlAttribute]
public string Id { get {return _id; } set {_id =value;} }
[XmlElement(Order = 0)]
public string Name { get {return _name; } set {_name = value;}}

}

After using WSDLImp [dec, 2007 version], I created a simple test that
calls the WebService to get the List<Foo>.
The call goes well, I can debug In .NET and D7, but when the answer to
the WebService is returned to D7,
the Foo.Id is Empty while the Foo.Name has the right value.

Is there an option on the WSDLImp or elsewhere that is required to get
the value of a class member that has the attribute XmlAttribute on it?

TIA,

CheGueVerra

CheGueVerra

unread,
Aug 29, 2008, 1:00:45 PM8/29/08
to
Hi All,

I resolved my problem, it seems the WSDLImp has trouble working with
XmlAttribute as such:

<Foo Id="HABS">
<Name>Montreal Canadiens</Name>
</Foo >

After comparing the SOAP Request and Response of the NET & Delphi
Client, both were the same, so it was just a
question of deserializing in Delphi.

I override the SOAPToObject procedure in the TFoo, so it looks
something like so:

procedure Foo.SOAPToObject(const RootNode, Node: IXMLNode; const
ObjConverter: IObjConverter);
begin
inherited SOAPToObject(RootNode, Node, ObjConverter);
if (Node.HasAttribute('Id')) then
Self.Id := Node.Attributes['Id'];
end;


The only issue I have with this solution is the fact that I have to
rewrite that part eachtime I'll re-import the WSDL
Is there a way to tell the WSDLImp to create that part?

TIA,
CheGueVerra

0 new messages