Board index » delphi » Namespace on each element

Namespace on each element


2006-11-04 02:24:09 AM
delphi227
Using D7.1, HTTPRIO, soDocument set, when generating the XML, the name space
is put just at the clas level with the assumption that the elements within
it will use this default namespace, for example:
<c xmlns="www.zz.com/2005/09/01/Cat/Category">
<Name>MISC</Name>
<Description></Description>
<SourceType>Manual</SourceType>
</c>
The web service I am using was developed using VS using ASP.net. They expect
the namespace to be on each element, does not seem to accept the default
namespace format.
<c>
<Name xmlns="www.zz.com/2005/09/01/Cat/Category">MISC</Name>
<Description
xmlns="www.zz.com/2005/09/01/Cat/Category"></Description>
<SourceType
xmlns="www.zz.com/2005/09/01/Cat/Category">Manual</SourceType>
</c>
Is there anyway to set flags to cause Delphi to do the other format with
namespace on each element? If not in 7.1, has that changed in more recent
Delphi versions? Is this a limitation caused by using VS at the web service
end?
Thanks, appreciate any help on this.
Wayne
 
 

Re:Namespace on each element

Hello Wayne,
Thanks for the post. The packet generated by Delphi and one expected are
quite different. IOW, it is not just that the service wants explicit
namespace declaration on each element's node, it wants 'c' to inherit its
parent namespace.
Delphi does not support all nuances of XML. The standard obstacle in this
kind of setup revolves around the 'elementFormDefault' attribute, that
governs whether local elements should be qualified. However, the case you
posted does not quite seem like that is the issue. If elementFormDefault is
qualified for a complexType 'c' that is in namepsace
"www.zz.com/2005/09/01/Cat/Category", then I'd expect the packet
you mentioned Delphi is sending. If it is unqualified, then I'd expect:
Quote
<c xmlns="www.zz.com/2005/09/01/Cat/Category">
<Name xmlns="">MISC</Name>
<Description xmlns=""></Description>
<SourceType xmlns="">Manual</SourceType>
</c>
Question:
======
1. Is the element 'c' above itself nested in another complex type? IOW, is
'c' a member of another type?
2. If yes, is that type in a different namespace from 'c'?
If it is possible to post an excerpt of the schema that describes the type
corresponding to 'c', it would help investigate. Thank you.
Cheers,
Bruneau.
 

Re:Namespace on each element

Hi Bruneau,
Thanks for the reply. Being a newbie at web services not sure of some of the
answers. The best thing for me to do is to show what Delphi is creating and
the sample I have from the web service. C is the second of two arguments
passsed to the web service Catalog_Category_Insert, the first is a token
obtained buy using a Login service.
This is the Delphi generated:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="www.w3.org/2001/XMLSchema"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<Catalog_Category_Insert xmlns="www.zz.com/2006/01/WebServices3">
<token>
<ExpirationDate>2006-11-03T14:13:35.4184112-05:00</ExpirationDate>
<ExpirationDateUTC>2006-11-03T19:13:35.4184112Z</ExpirationDateUTC>
<UserBvin>a8a3e4d9-a8c1-4d5a-859c-693f314aefc8</UserBvin>
<TokenRejected>false</TokenRejected>
<IsExpired>false</IsExpired>
</token>
<c xmlns="www.zz.com/2005/09/01/Cat/Category">
<ParentId>0</ParentId>
<Name>MISC</Name>
<Description></Description>
<SourceType>Manual</SourceType>
</c>
</Catalog_Category_Insert>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This is the sample from web services docs:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="www.w3.org/2001/XMLSchema"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<Catalog_Category_Insert xmlns="www.zz.com/2006/01/WebServices3">
<token>
<ExpirationDate>2006-11-03T14:13:35.4184112-05:00</ExpirationDate>
<ExpirationDateUTC>2006-11-03T19:13:35.4184112Z</ExpirationDateUTC>
<UserBvin>a8a3e4d9-a8c1-4d5a-859c-693f314aefc8</UserBvin>
<TokenRejected>false</TokenRejected>
<IsExpired>false</IsExpired>
</token>
<c>
<ParentId
xmlns="www.zz.com/2005/09/01/Cat/Category">0</ParentId>
<Name xmlns="www.zz.com/2005/09/01/Cat/Category">MISC</Name>
<Description
xmlns="www.zz.com/2005/09/01/Cat/Category"></Description>
<SourceType
xmlns="www.zz.com/2005/09/01/Cat/Category">Manual</SourceType>
</c>
</Catalog_Category_Insert>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The structure for c looks like this. Note I dropped some of the properties
in the samples above just to keep it shorter:
Category = class(BusinessEntityBase8)
private
FParentId: WideString;
FName: WideString;
FDescription: WideString;
FSourceType: CategorySourceType;
FMetaKeywords: WideString;
FMetaDescription: WideString;
FMetaTitle: WideString;
FImageUrl: WideString;
FBannerImageUrl: WideString;
FLatestProductCount: Integer;
FCustomPageUrl: WideString;
FCustomPageOpenInNewWindow: Boolean;
FMenuOffImageUrl: WideString;
FMenuOnImageUrl: WideString;
FShowInTopMenu: Boolean;
FHidden: Boolean;
FTemplateName: WideString;
FPreContentColumnId: WideString;
FPostContentColumnId: WideString;
FRewriteUrl: WideString;
FShowTitle: Boolean;
FCriteria: WideString;
FCustomPageId: WideString;
FPreTransformDescription: WideString;
FKeywords: WideString;
published
property ParentId: WideString read FParentId write FParentId;
property Name: WideString read FName write FName;
property Description: WideString read FDescription write FDescription;
property SourceType: CategorySourceType read FSourceType write
FSourceType;
property MetaKeywords: WideString read FMetaKeywords write
FMetaKeywords;
property MetaDescription: WideString read FMetaDescription write
FMetaDescription;
property MetaTitle: WideString read FMetaTitle write FMetaTitle;
property ImageUrl: WideString read FImageUrl write FImageUrl;
property BannerImageUrl: WideString read FBannerImageUrl write
FBannerImageUrl;
property LatestProductCount: Integer read FLatestProductCount write
FLatestProductCount;
property CustomPageUrl: WideString read FCustomPageUrl write
FCustomPageUrl;
property CustomPageOpenInNewWindow: Boolean read
FCustomPageOpenInNewWindow write FCustomPageOpenInNewWindow;
property MenuOffImageUrl: WideString read FMenuOffImageUrl write
FMenuOffImageUrl;
property MenuOnImageUrl: WideString read FMenuOnImageUrl write
FMenuOnImageUrl;
property ShowInTopMenu: Boolean read FShowInTopMenu write
FShowInTopMenu;
property Hidden: Boolean read FHidden write FHidden;
property TemplateName: WideString read FTemplateName write
FTemplateName;
property PreContentColumnId: WideString read FPreContentColumnId write
FPreContentColumnId;
property PostContentColumnId: WideString read FPostContentColumnId write
FPostContentColumnId;
property RewriteUrl: WideString read FRewriteUrl write FRewriteUrl;
property ShowTitle: Boolean read FShowTitle write FShowTitle;
property Criteria: WideString read FCriteria write FCriteria;
property CustomPageId: WideString read FCustomPageId write
FCustomPageId;
property PreTransformDescription: WideString read
FPreTransformDescription write FPreTransformDescription;
property Keywords: WideString read FKeywords write FKeywords;
end;
Thanks, Wayne
"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
Quote
Hello Wayne,

Thanks for the post. The packet generated by Delphi and one expected are
quite different. IOW, it is not just that the service wants explicit
namespace declaration on each element's node, it wants 'c' to inherit its
parent namespace.

Delphi does not support all nuances of XML. The standard obstacle in this
kind of setup revolves around the 'elementFormDefault' attribute, that
governs whether local elements should be qualified. However, the case you
posted does not quite seem like that is the issue. If elementFormDefault is
qualified for a complexType 'c' that is in namepsace
"www.zz.com/2005/09/01/Cat/Category", then I'd expect the
packet
you mentioned Delphi is sending. If it is unqualified, then I'd expect:

><c xmlns="www.zz.com/2005/09/01/Cat/Category">
><Name xmlns="">MISC</Name>
><Description xmlns=""></Description>
><SourceType xmlns="">Manual</SourceType>
></c>


Question:
======
1. Is the element 'c' above itself nested in another complex type? IOW, is
'c' a member of another type?
2. If yes, is that type in a different namespace from 'c'?

If it is possible to post an excerpt of the schema that describes the type
corresponding to 'c', it would help investigate. Thank you.

Cheers,

Bruneau.


 

Re:Namespace on each element

Hello,
Would it be possible to see the XML schema (or whole WSDL) describing what
this service expects. Basically, according to the binding generated by
Delphi, the type 'Catalog_Category_Insert' is in namespace
www.zz.com/2006/01/WebServices3 while the type of its element, 'c',
is in namespace www.zz.com/2005/01/Cat/Category. To get the element
'c' not to specify a namespace would imply that it is also in the namespace
of the outer type. That can be done by tweaking the binding. However, to
then get 'ParentId', 'Name', etc to specify a namespace would imply that
they are not in the namespace of 'c' - which would be rather unusual but not
impossible.
All of this should be described in the XML schema, which typically is
embedded within the WSDL document or sometimes is referred to (via an
<include...>, or <import...>or <redefine....>element).
If it is not possible to post the WSDL/Schema, I can try to put together some
snippet that achieves what you're after. It would involve the use of strong
aliases.
Cheers,
Bruneau.
 

Re:Namespace on each element

Hi Bruneau,
I have put the unit generated from importing the WSDL in the attachments
newsgroup and marked it WSDL from Wayne. I hope that is enough to look at.
Wayne
"Wayne L" <XXXX@XXXXX.COM>writes
Quote
Hi Bruneau,

Thanks for the reply. Being a newbie at web services not sure of some of
the answers. The best thing for me to do is to show what Delphi is
creating and the sample I have from the web service. C is the second of
two arguments passsed to the web service Catalog_Category_Insert, the
first is a token obtained buy using a Login service.

This is the Delphi generated:

<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="www.w3.org/2001/XMLSchema"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<Catalog_Category_Insert
xmlns="www.zz.com/2006/01/WebServices3">
<token>
<ExpirationDate>2006-11-03T14:13:35.4184112-05:00</ExpirationDate>
<ExpirationDateUTC>2006-11-03T19:13:35.4184112Z</ExpirationDateUTC>
<UserBvin>a8a3e4d9-a8c1-4d5a-859c-693f314aefc8</UserBvin>
<TokenRejected>false</TokenRejected>
<IsExpired>false</IsExpired>
</token>
<c xmlns="www.zz.com/2005/09/01/Cat/Category">
<ParentId>0</ParentId>
<Name>MISC</Name>
<Description></Description>
<SourceType>Manual</SourceType>
</c>
</Catalog_Category_Insert>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This is the sample from web services docs:

<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="www.w3.org/2001/XMLSchema"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<Catalog_Category_Insert
xmlns="www.zz.com/2006/01/WebServices3">
<token>
<ExpirationDate>2006-11-03T14:13:35.4184112-05:00</ExpirationDate>
<ExpirationDateUTC>2006-11-03T19:13:35.4184112Z</ExpirationDateUTC>
<UserBvin>a8a3e4d9-a8c1-4d5a-859c-693f314aefc8</UserBvin>
<TokenRejected>false</TokenRejected>
<IsExpired>false</IsExpired>
</token>
<c>
<ParentId
xmlns="www.zz.com/2005/09/01/Cat/Category">0</ParentId>
<Name xmlns="www.zz.com/2005/09/01/Cat/Category">MISC</Name>
<Description
xmlns="www.zz.com/2005/09/01/Cat/Category"></Description>
<SourceType
xmlns="www.zz.com/2005/09/01/Cat/Category">Manual</SourceType>
</c>
</Catalog_Category_Insert>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The structure for c looks like this. Note I dropped some of the properties
in the samples above just to keep it shorter:

Category = class(BusinessEntityBase8)
private
FParentId: WideString;
FName: WideString;
FDescription: WideString;
FSourceType: CategorySourceType;
FMetaKeywords: WideString;
FMetaDescription: WideString;
FMetaTitle: WideString;
FImageUrl: WideString;
FBannerImageUrl: WideString;
FLatestProductCount: Integer;
FCustomPageUrl: WideString;
FCustomPageOpenInNewWindow: Boolean;
FMenuOffImageUrl: WideString;
FMenuOnImageUrl: WideString;
FShowInTopMenu: Boolean;
FHidden: Boolean;
FTemplateName: WideString;
FPreContentColumnId: WideString;
FPostContentColumnId: WideString;
FRewriteUrl: WideString;
FShowTitle: Boolean;
FCriteria: WideString;
FCustomPageId: WideString;
FPreTransformDescription: WideString;
FKeywords: WideString;
published
property ParentId: WideString read FParentId write FParentId;
property Name: WideString read FName write FName;
property Description: WideString read FDescription write FDescription;
property SourceType: CategorySourceType read FSourceType write
FSourceType;
property MetaKeywords: WideString read FMetaKeywords write
FMetaKeywords;
property MetaDescription: WideString read FMetaDescription write
FMetaDescription;
property MetaTitle: WideString read FMetaTitle write FMetaTitle;
property ImageUrl: WideString read FImageUrl write FImageUrl;
property BannerImageUrl: WideString read FBannerImageUrl write
FBannerImageUrl;
property LatestProductCount: Integer read FLatestProductCount write
FLatestProductCount;
property CustomPageUrl: WideString read FCustomPageUrl write
FCustomPageUrl;
property CustomPageOpenInNewWindow: Boolean read
FCustomPageOpenInNewWindow write FCustomPageOpenInNewWindow;
property MenuOffImageUrl: WideString read FMenuOffImageUrl write
FMenuOffImageUrl;
property MenuOnImageUrl: WideString read FMenuOnImageUrl write
FMenuOnImageUrl;
property ShowInTopMenu: Boolean read FShowInTopMenu write
FShowInTopMenu;
property Hidden: Boolean read FHidden write FHidden;
property TemplateName: WideString read FTemplateName write
FTemplateName;
property PreContentColumnId: WideString read FPreContentColumnId write
FPreContentColumnId;
property PostContentColumnId: WideString read FPostContentColumnId
write FPostContentColumnId;
property RewriteUrl: WideString read FRewriteUrl write FRewriteUrl;
property ShowTitle: Boolean read FShowTitle write FShowTitle;
property Criteria: WideString read FCriteria write FCriteria;
property CustomPageId: WideString read FCustomPageId write
FCustomPageId;
property PreTransformDescription: WideString read
FPreTransformDescription write FPreTransformDescription;
property Keywords: WideString read FKeywords write FKeywords;
end;

Thanks, Wayne

"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
news:454b8e97$XXXX@XXXXX.COM...
>Hello Wayne,
>
>Thanks for the post. The packet generated by Delphi and one expected are
>quite different. IOW, it is not just that the service wants explicit
>namespace declaration on each element's node, it wants 'c' to inherit its
>parent namespace.
>
>Delphi does not support all nuances of XML. The standard obstacle in this
>kind of setup revolves around the 'elementFormDefault' attribute, that
>governs whether local elements should be qualified. However, the case you
>posted does not quite seem like that is the issue. If elementFormDefault
>is
>qualified for a complexType 'c' that is in namepsace
>"www.zz.com/2005/09/01/Cat/Category", then I'd expect the
>packet
>you mentioned Delphi is sending. If it is unqualified, then I would
>expect:
>
>><c xmlns="www.zz.com/2005/09/01/Cat/Category">
>><Name xmlns="">MISC</Name>
>><Description xmlns=""></Description>
>><SourceType xmlns="">Manual</SourceType>
>></c>
>
>
>Question:
>======
>1. Is the element 'c' above itself nested in another complex type? IOW,
>is
>'c' a member of another type?
>2. If yes, is that type in a different namespace from 'c'?
>
>If it is possible to post an excerpt of the schema that describes the type
>corresponding to 'c', it would help investigate. Thank you.
>
>Cheers,
>
>Bruneau.
>
>


 

Re:Namespace on each element

Thank you. I will take a look at this tonight or tomorrow.
Cheers,
Bruneau.
 

Re:Namespace on each element

Hello,
Actually, what I am after is the WSDL file - not the .pas binding generated
by Delphi. I want to see the XML schema declaration for the types involved
to understand why the service is looking for such a packet. I tried to
access the WSDL directly (
72.148.65.227/bvc5release/webservices3.asmx?wsdl ) but was not
successful.
Feel free to email be (bbabet at borland.com) the file also.
Cheers,
Bruneau.
PS: I will still work on something that produces the packet you're after
although I would like to see the schema that warrants such a packet.
 

Re:Namespace on each element

Hi Bruneau,
I shortened up the url just for explanation purposes, plus that test web
site is down all weekend. I will put up the actual url so you can see the
WSDL document on Monday if that will help.
Wayne
"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
Quote
Hello,

Actually, what I am after is the WSDL file - not the .pas binding generated
by Delphi. I want to see the XML schema declaration for the types involved
to understand why the service is looking for such a packet. I tried to
access the WSDL directly (
72.148.65.227/bvc5release/webservices3.asmx?wsdl ) but was not
successful.

Feel free to email be (bbabet at borland.com) the file also.

Cheers,

Bruneau.

PS: I will still work on something that produces the packet you're after
although I would like to see the schema that warrants such a packet.


 

Re:Namespace on each element

Hi bruneau,
The web services are up right now. Below is the link.
72.148.65.227/bvc5/webservices3.asmx?wsdl
Wayne
"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
Quote
Hello,

Actually, what I am after is the WSDL file - not the .pas binding generated
by Delphi. I want to see the XML schema declaration for the types involved
to understand why the service is looking for such a packet. I tried to
access the WSDL directly (
72.148.65.227/bvc5release/webservices3.asmx?wsdl ) but was not
successful.

Feel free to email be (bbabet at borland.com) the file also.

Cheers,

Bruneau.

PS: I will still work on something that produces the packet you're after
although I would like to see the schema that warrants such a packet.


 

Re:Namespace on each element

Hi Bruneau,
I read in other threads you have been working {*word*156} the WSDL import tool
and will be posting that to code central. Would love to get my hands on that
when you are ready. How will you be notifying people it is there when it is
ready?
Also appreciate you taking time to look at my issue.
Wayne
"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
Quote
Hello,

Actually, what I am after is the WSDL file - not the .pas binding generated
by Delphi. I want to see the XML schema declaration for the types involved
to understand why the service is looking for such a packet. I tried to
access the WSDL directly (
72.148.65.227/bvc5release/webservices3.asmx?wsdl ) but was not
successful.

Feel free to email be (bbabet at borland.com) the file also.

Cheers,

Bruneau.

PS: I will still work on something that produces the packet you're after
although I would like to see the schema that warrants such a packet.


 

Re:Namespace on each element

Thank you. I am going to try to pull the WSDL right now.
More later...
Bruneau.
 

Re:Namespace on each element

Thank you for the link. Once I spotted an operation that would contain a
packet similar to what you posted, I jumped to MindReef's online analyzer
( www.mindreef.net/tide/scopeit/start.do - a wonderful tool for this
kind of issue) and indeed it confirms that the expected packet should be:
<soap:Body>
<tns:Catalog_Category_Insert>
<tns:token>
.... leaving out some details here ...
</tns:token>
<tns:c>
<s12:LastUpdated/>
<s12:Name/>
xmlns:s12="www.zz.com/bvc5/schemas/2005/09/01/Catalog/Category"
xmlns:tns="www.zz.com/Schemas/Bvc5/2006/01/WebServices3"
This is equivalent to what the service expects (there are zillion of ways to
express the same XML packet when it comes to namespaces) and does not match
what Delphi is generating.
I'll need to research this but I suspect the problem to be related to the
<import ...>statements that the 'tns' namespace has:
<s:schema elementFormDefault="qualified"
targetNamespace="www.bvsoftware.com/Schemas/Bvc5/2006/01/WebServices3
">
<s:import
namespace="www.bvsoftware.com/bvc5/schemas/2005/09/01/Catalog/Categor
y" />
I'll confer with the resident XML expert here and relay my findings as soon
as possible.
Cheers,
Bruneau.
 

Re:Namespace on each element

Hi Bruneau,
Thanks a ton for all your help. Will wait to hear from you.
Wayne
"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
Quote
Thank you for the link. Once I spotted an operation that would contain a
packet similar to what you posted, I jumped to MindReef's online analyzer
( www.mindreef.net/tide/scopeit/start.do - a wonderful tool for
this
kind of issue) and indeed it confirms that the expected packet should be:

<soap:Body>
<tns:Catalog_Category_Insert>
<tns:token>
.... leaving out some details here ...
</tns:token>
<tns:c>
<s12:LastUpdated/>
<s12:Name/>


xmlns:s12="www.zz.com/bvc5/schemas/2005/09/01/Catalog/Category"
xmlns:tns="www.zz.com/Schemas/Bvc5/2006/01/WebServices3"


This is equivalent to what the service expects (there are zillion of ways
to
express the same XML packet when it comes to namespaces) and does not
match
what Delphi is generating.

I'll need to research this but I suspect the problem to be related to the
<import ...>statements that the 'tns' namespace has:

<s:schema elementFormDefault="qualified"
targetNamespace="www.bvsoftware.com/Schemas/Bvc5/2006/01/WebServices3
">
<s:import
namespace="www.bvsoftware.com/bvc5/schemas/2005/09/01/Catalog/Categor
y" />


I'll confer with the resident XML expert here and relay my findings as
soon
as possible.

Cheers,

Bruneau.


 

Re:Namespace on each element

Hello,
I believe I have found the problem. Like most serialization issues with Delphi
SOAP it is basically related to (dubious) assumptions made simply because
Delphi RTTI cannot capture the richness of an XML schema. The service
expects:
<a xmlns="ns1">
<c>
<d xmlns="ns2">xxxx</d>
<e xmlns="ns2">xxxx</e>
Delphi is currently generating
<a xmlns="ns1">
<c xmlns="ns2"><<<==
<d>xxxx</d>
<e>xxxx</e>
The problematic node is <c>. I am aiming for the following - which is
equivalent:
<a xmlns="ns1">
<x:c xmlns:x="ns1" xmlns="ns2"><<<==
<d>xxxx</d>
<e>xxxx</e>
IOW, add & use a prefix at 'c' that corresponds to a's namespace.
I'll let you know more later tonight.
Cheers,
Bruneau.
 

Re:Namespace on each element

Hello,
About the new importer, I am happy forward anyone a copy. I have not pursued
CodeCentral because (partly, it is a little hectic here currently and) my
request for an official HOTFIX has been approved and the changes are being
tested.
Let me know if you'd like to try it out.
Cheers,
Bruneau.