Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Move Namespace references from Body to Envelope?



Permlink Replies: 2 - Last Post: Apr 23, 2018 11:40 PM Last Post By: Adam Hair
Adam Hair

Posts: 18
Registered: 7/26/17
Move Namespace references from Body to Envelope?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2018 5:18 PM
Hi,

I've used WSDL importer to import WSDL files. This allows me to generate a SOAP Request as per the following:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<SOAP-ENV:Body xmlns:NS1="http://agriculture.gov.au/nexdoc/common/EnumTypes_1.0" xmlns:NS2="http://agriculture.gov.au/nexdoc/common/CommonTypes_1.0" xmlns:NS3="http://agriculture.gov.au/nexdoc/common/rex/CommonTypes_1.0">
		<LodgeRex xmlns="http://agriculture.gov.au/nexdoc/LodgeRexSoap_1.0">
			<exportDetails>
...


However according to the department we are communicating with, they are expecting a SOAP header with the following:
<?xml version="1.0"?>
<soapenv:Envelope xmlns:com1="http://agriculture.gov.au/nexdoc/common/rex/CommonTypes_1.0" xmlns:com="http://agriculture.gov.au/nexdoc/common/CommonTypes_1.0" xmlns:lod="http://agriculture.gov.au/nexdoc/LodgeRexSoap_1.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<soapenv:Body>
		<lod:LodgeRex>
			<lod:exportDetails>
...


From what I can gather, I need the namespaces to be relocated from the body to the envelope section. I was just wondering what would be the correct method in relocating these.

Thanks & Regards

Adam.
Adam Hair

Posts: 18
Registered: 7/26/17
Re: Move Namespace references from Body to Envelope?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 10:10 PM   in response to: Adam Hair in response to: Adam Hair
Another developer has helped me with this and I've found that I was creating the header incorrectly.

I was creating/setting the header using:

Procedure SetRIOHeader(RIO: THttpRIO);
var
Token: AuthTokens;
Cred: Security;
begin
Token := AuthTokens.create;
Token.AppToken := 'xxxxx';
Token.ClientToken := 'yyyyy';

Cred := Security.create;
Cred.UsernameToken := UsernameToken.Create;
Cred.UsernameToken.Username := 'zzzzzz';
Cred.UsernameToken.Password := PasswordString.Create;

Cred.UsernameToken.Password.Type_ := 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText';
Cred.UsernameToken.Password.Text := 'password';

(RIO as ISOAPHeaders).Send(Token);
(RIO as ISOAPHeaders).Send(Cred);
end;

... and calling a procedure to set the header.

What I should have been doing was creating a class, and applying it, such as:

type
TMyAuth = class
private
class var
FCred: Security;
FToken: AuthTokens;
public
class constructor Create;
class destructor Destroy;
class property Token: AuthTokens read FToken;
class property Cred: Security read FCred;
end;

implementation

uses
System.SysUtils;

{ TMyAuth }

class constructor TMyAuth.Create;
begin
FCred := Security.Create;
FCred.UsernameToken := UsernameToken.Create;
FCred.UsernameToken.Username := 'zzzzz';
FCred.UsernameToken.Password := PasswordString.Create;
FCred.UsernameToken.Password.type_ := 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText';
FCred.UsernameToken.Password.Text := 'password';

FToken := AuthTokens.Create;
FToken.AppToken := 'xxxxx';
FToken.ClientToken := 'yyyyy';
end;

class destructor TMyAuth.Destroy;
begin
FreeAndNil(FToken);
FreeAndNil(FCred);
end;

And calling it with:

(RIO1 as ISOAPHeaders).Send(TMyAuth.Token);
(RIO1 as ISOAPHeaders).Send(TMyAuth.Cred);
_Response := (RIO1 as MyService.Port).Lodge(LR);


Hopefully this helps someone else down the track if searching through the newsgroups...

Adam Hair

Posts: 31
Registered: 9/2/00
Re: Move Namespace references from Body to Envelope?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 11:40 PM   in response to: Adam Hair in response to: Adam Hair
I should clarify...

This doesn't actually relocate the namespaces to the header - however it does appear to resolve some issues with the transmission.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02