Groups > Borland > Dellphi web services soap > Re: SOAP Header question




SOAP Header question

SOAP Header question
Thu, 06 Mar 2008 19:10:40 +010
Dear all

With Delphi 2006 (Delphi SOAP Runtime and Importer Update is installed) 
I managed to create the SOAP Header.

This is how it should look like:


<soapenv:Header
xmlns:aws="http://security.amazonaws.com/doc/2007-01-01/">
<aws:AWSAccessKeyId>1D9FVRAYCP1VJS767E02EXAMPLE</aws:AWSAccessKeyId>

<aws:Timestamp>2008-02-10T23:59:59Z</aws:Timestamp>
<aws:Signature>SZf1CHmQ/nrZbsrC13hCZS061ywsEXAMPLE</aws:Signature>
</soapenv:Header>

This is what I get so far:

<SOAP-ENV:Header>
   <TAuth 
xmlns="http://security.amazonaws.com/doc/2008-01-01/">
     <AWSAccessKeyId>1D9FVRAYCP1VJS767E02EXAMPLE</AWSAccessKeyId>
     <Timestamp>2008-03-06T18:53:49.968+01:00</Timestamp>
     <Signature>SZf1CHmQ/nrZbsrC13hCZS061ywsEXAMPLE</Signature>
   </TAuth>
</SOAP-ENV:Header>


In Delphi I use this initialization:

   RemClassRegistry.RegisterXSClass(TAuth, 
'http://security.amazonaws.com/doc/2008-01-01/', 'TRequestHeader');
   InvRegistry.RegisterHeaderClass(TypeInfo(QueueServicePortType), 
TAuth, 'Header', 'http://security.amazonaws.com/doc/2008-01-01/'); {and 
the header}

and this authorization class:

   TAuth = class(TSoapHeader)
   private
     FAWSAccessKeyId: string;
     FTimestamp: TDateTime;
     FSignature: string;
   published
     property AWSAccessKeyId: string (* index (IS_REF) *) read 
FAWSAccessKeyId write FAWSAccessKeyId;
     property Timestamp: TDateTime read FTimestamp write FTimestamp;
     property Signature: string read FSignature write FSignature;
   end;

Differences as far as I can see:
* the Header should have a namespace
* the <TAuth> element should not appear
* the namespace-prefix (aws) is missing

I thinnk that the I am already very close to the target.
Always hoping that it is a just a simple problem :)

Maybe something like RemClassRegistry.RegisterSerializeOptions...

Any help would be very appreciated

Post Reply
Re: SOAP Header question
Tue, 18 Mar 2008 13:53:36 -080
Hello,

> Differences as far as I can see:
> * the Header should have a namespace
> * the <TAuth> element should not appear
> * the namespace-prefix (aws) is missing

Item #1 and #2 above are related because Delphi SOAP assumes the header is
<TAuth...>. Whether one declares 'xmlns:aws' at the 'Header' element or
at
the node that actually uses that prefix is a matter of style and preference.

I'm puzzled that there's no element enclosing the AWSAccessKeyId, Signature
and TimeStamp. If that indeed the case you'll probably want to use three
headers and tag each with the 'xoSimpleTypeWrapper' serialization flag. As
in:


  //
************************************************************************ //
  // XML       : ValidFrom, alias
  // Namespace : urn:soap_headers
  // Serializtn: [xoSimpleTypeWrapper]
  // Info      : Header
  //
************************************************************************ //
  ValidFrom = class(TSOAPHeader)
  private
    FValue: TXSDateTime;
  public
    destructor Destroy; override;
  published
    property Value: TXSDateTime  read FValue write FValue;
  end;

  RemClassRegistry.RegisterXSClass(ValidFrom, 'urn:soap_headers',
'ValidFrom');
  RemClassRegistry.RegisterSerializeOptions(ValidFrom,
[xoSimpleTypeWrapper]);


The above generates:


<SOAP-ENV:Header>
    <ValidFrom
xmlns="urn:soap_headers">2008-03-17T12:05:08.765-08:00</ValidFro
m>
  </SOAP-ENV:Header>

Please let me know if the above does not help.

Cheers,

Bruneau.

Post Reply
Re: SOAP Header question
Thu, 20 Mar 2008 15:01:13 +010
Jean-Marie Babet schrieb:

> I'm puzzled that there's no element enclosing the AWSAccessKeyId,
Signature
> and TimeStamp. If that indeed the case you'll probably want to use three
> headers and tag each with the 'xoSimpleTypeWrapper' serialization flag. 

This did the trick, thank you very much for your help!

No need for quick'n'dirty tricks anymore :)

Best Regards
Michael Justin
-- 
betasoft - Software for Delphi™ and for the Java™ platform
http://www.mikejustin.com/
Post Reply
about | contact