Quantcast
Channel: WinDev Forum
Viewing all articles
Browse latest Browse all 1914

[WD19] How to build and sign an XML file?

$
0
0
Hi all,

I need to build and sign an XML file called Application Request and finally sending it to a bank using a webservice called CorporateFileService. This goes beyond my procedurally thinking brains, so I need help from xml/ws specialists to get started.

The necessary schema, certificate and WSDL files are available here:
[www.nordea.fi]

Aditional documents are here:
[www.nordea.fi]

And the detailed message descriptions (in English, despite the link text's language) are here:
[www.finanssiala.fi]

To start with, I need to build an "ApplicationRequest" XML file like below, where ... (3 dots) dots indicates that a portion of the string has been cut away. I have all the data prepared, the content base 64 -coded and the certificate containing the provate key in a separate file, I just need to know how to insert them into an xml file like this:
(Note: <> have been replaced with [] to keep it readable, the smiley has replaced character pair ":" + "p")
[?xml version="1.0" encoding="UTF-8"?]
[ApplicationRequest xmlns="[bxd.fi];]
	[CustomerId]679155330[/CustomerId]
	[Command]UploadFile[/Command]
	[Timestamp]2010-09-13T13:04:57.768+03:00[/Timestamp]
	[Environment]PRODUCTION[/Environment]
	[TargetId]11111111A1[/TargetId]
	[SoftwareId]MyProgram[/SoftwareId]
	[FileType]NDCORPAYS[/FileType]
	[Content]PD94bWwgdmVy ... dW1lbnQ+[/Content]
	[Signature xmlns="[www.w3.org];]
		[SignedInfo]
			[CanonicalizationMethod Algorithm="[www.w3.org]]
			[SignatureMethod Algorithm="[www.w3.org]]
			[Reference URI=""]
				[Transforms]
					[Transform Algorithm="[www.w3.org]]
				[/Transforms]
				[DigestMethod Algorithm="[www.w3.org]]
				[DigestValue]qBXne/Fko6yvVadNZVpbQQ8afWI=[/DigestValue]
			[/Reference]
		[/SignedInfo]
		[SignatureValue]fOJ3EwA ... 4Kd0o=[/SignatureValue]
		[KeyInfo]
			[X509Data]
				[X509Certificate]MIID+jCCAuKg ... BPkZp8OKo=[/X509Certificate]
				[X509IssuerSerial]
					[X509IssuerName]2.5.4.5=#130b3531363430362d30313230,CN=Nordea role-certificates CA 01,O=Nordea Bank AB (publ),C=SE[/X509IssuerName]
					[X509SerialNumber]13070788[/X509SerialNumber]
				[/X509IssuerSerial]
			[/X509Data]
		[/KeyInfo]
	[/Signature]
[/ApplicationRequest]
The schema looks like this (middle part cut away):
[?xml version="1.0" encoding="UTF-8"?]
[!-- edited with XMLSpy v2009 (http://www.altova.com) by Petri Luoto (Nordea) --]
[xs:schema xmlns:xs="[www.w3.org]; xmlns:bxd="[bxd.fi]; xmlns:ds="[www.w3.org]; targetNamespace="[bxd.fi]; elementFormDefault="qualified" attributeFormDefault="unqualified"]
	[xs:import namespace="[www.w3.org]; schemaLocation="xmldsig-core-schema.xsd"/]
	[xs:element name="ApplicationRequest"]
		[xs:annotation]
			[xs:documentation]Wrapper for data. Used for transmitting data. Can be XML Digital Signed.[/xs:documentation]
		[/xs:annotation]
		[xs:complexType]
			[xs:sequence]
				[xs:element name="CustomerId" nillable="false"]
					[xs:simpleType]
						[xs:restriction base="xs:string"]
							[xs:minLength value="1"/]
							[xs:maxLength value="16"/]
						[/xs:restriction]
					[/xs:simpleType]
				[/xs:element]
				[xs:element name="Command" nillable="false" minOccurs="0"]
					[xs:simpleType]
						[xs:restriction base="xs:string"]
							[xs:maxLength value="32"/]
							[xs:minLength value="1"/]
						[/xs:restriction]
					[/xs:simpleType]
				[/xs:element]
				[xs:element name="Timestamp" type="xs:dateTime"/]
... (here many elements have been cut away) ...
				[xs:element name="Content" type="xs:base64Binary" nillable="true" minOccurs="0"/]
				[xs:element ref="ds:Signature" minOccurs="0"/]
			[/xs:sequence]
		[/xs:complexType]
	[/xs:element]
	[xs:simpleType name="EnvironmentCode"]
		[xs:annotation]
			[xs:documentation]Production or Test[/xs:documentation]
		[/xs:annotation]
		[xs:restriction base="xs:NMTOKEN"]
			[xs:pattern value="(PRODUCTION|TEST)"/]
		[/xs:restriction]
	[/xs:simpleType]
[/xs:schema]
So how do I code this?
I suppose I need to start with something like this:
xAppReq is xmlDocument [description="ApplicationRequest"] 
xNode is xmlNode //Or dynamic?!?!?
How to continue?

Best regards
Ola

P.S. Fixed "smiled" character pair to ":" + "p" :-).
Added [?xml version="1.0" encoding="UTF-8"?] to Application request's beginning.

Viewing all articles
Browse latest Browse all 1914

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>