about IComponentConnector2 - winrt-xaml

I have the following code
struct MainPage : PageT<MainPage,IComponentConnector,IComponentConnector2>
{...}
How GetBindingConnector get called? As a comparison, I know if I set the ConnectionId attribute on the Xaml page, IComponentConnector.Connect will get called. So there must exist some attribute(s) that will trigger GetBindingConnector, then what's that? Many thanks!!!
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button Content="Test" x:ConnectionId="1"/>
</Page>
New Update
1,Using x:Bind and GetBindingConnector called
<Page
x:Class="BlankApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BlankApp1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Button x:Name="myButton" Content="{x:Bind MyProperty}"/>
</Page>
and the dump of xbf
PushScopeAddNamespace (prefix=(null), namespace=http://schemas.microsoft.com/winfx/2006/xaml/presentation)
AddNamespace (prefix=x, namespace=http://schemas.microsoft.com/winfx/2006/xaml)
AddNamespace (prefix=local, namespace=using:BlankApp1)
AddNamespace (prefix=d, namespace=http://schemas.microsoft.com/expression/blend/2008)
AddNamespace (prefix=mc, namespace=http://schemas.openxmlformats.org/markup-compatibility/2006)
CreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Page)
SetConnectionId (Id=type=Signed, value=1)
CheckPeerType (x:Class=BlankApp1.MainPage)
PushScopeCreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Button)
SetConnectionId (Id=type=Signed, value=2)
SetName (x:Name=myButton)
EndInitPopScope
SetValue (property=Windows.UI.Xaml.Controls.UserControl.Content)
EndInitPopScope
2, Not using x:Bind:
<Page
x:Class="BlankApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BlankApp1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Button x:Name="myButton"/>
</Page>
and the dump of xbf
PushScopeAddNamespace (prefix=(null), namespace=http://schemas.microsoft.com/winfx/2006/xaml/presentation)
AddNamespace (prefix=x, namespace=http://schemas.microsoft.com/winfx/2006/xaml)
AddNamespace (prefix=local, namespace=using:BlankApp1)
AddNamespace (prefix=d, namespace=http://schemas.microsoft.com/expression/blend/2008)
AddNamespace (prefix=mc, namespace=http://schemas.openxmlformats.org/markup-compatibility/2006)
CheckPeerType (x:Class=BlankApp1.MainPage)
CreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Page)
PushScopeCreateTypeBeginInit (type=Windows.UI.Xaml.Controls.Button)
SetConnectionId (Id=type=Signed, value=2)
SetName (x:Name=myButton)
EndInitPopScope
SetValue (property=Windows.UI.Xaml.Controls.UserControl.Content)
EndInitPopScope
3, differences of the 2 dumps
I'm not sure if this is the root cause that makes difference.

Related

Azure API Management WSDL Import Failing on SOAP Encoding's Array Type

I'm trying to create an API from a WSDL and currently getting this error back from Azure APIM during the import step:
Error: Parsing error : Line 17, position 22: Unable to import API from WSDL: Undefined
complexType 'http://schemas.xmlsoap.org/soap/encoding/:Array' is used as a base for
complex type restriction.
I'm gathering that the Array type is not WSI-compliant, but would love insight as to how I can tinker with the WSDL to make it work? I don't own the service which generated the WSDL, but the WSDL hasn't changed since it was incepted and the provider has said it's okay for us to mess with it to get the Azure APIM import step to work. Just meaning, since Azure APIM's a passthrough what can I slice out of the WSDL which would still (a) let Azure APIM import it, and (b) allow the calls to successfully flow through Azure APIM at runtime?
I slimmed down the WSDL to this, but let me know if anything looks off as the original WSDL is ~5,500 lines:
<?xml version="1.0"?>
<definitions
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s0="urn:ChestersCopperpotsServiceSoap"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:atls="http://tempuri.org/vc/atl/server/"
targetNamespace="urn:ChestersCopperpotsServiceSoap"
xmlns="http://schemas.xmlsoap.org/wsdl/"
>
<types>
<s:schema targetNamespace="urn:ChestersCopperpotsServiceSoap" attributeFormDefault="qualified" elementFormDefault="qualified">
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<s:complexType name="CMessage">
<s:sequence>
<s:element name="Code" type="s:int"/>
<s:element name="Text" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="GetMessages_return_Array">
<s:complexContent>
<s:restriction base="soapenc:Array">
<s:attribute ref="soapenc:arrayType" wsdl:arrayType="s0:CMessage[]"/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:complexType name="MyHeader">
<s:sequence>
<s:element name="m_SessionID" type="s:string"/>
</s:sequence>
</s:complexType>
</s:schema>
</types>
<message name="GetMessagesIn">
</message>
<message name="GetMessagesOut">
<part name="return" type="s0:GetMessages_return_Array"/>
</message>
<message name="m_Header">
<part name="m_Header" type="s0:MyHeader"/>
</message>
<portType name="ChestersCopperpotsServiceSoap">
<operation name="GetMessages">
<input message="s0:GetMessagesIn"/>
<output message="s0:GetMessagesOut"/>
</operation>
</portType>
<binding name="ChestersCopperpotsServiceSoap" type="s0:ChestersCopperpotsServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="GetMessages">
<soap:operation soapAction="#GetMessages" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:ChestersCopperpotsService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<soap:header message="s0:m_Header" part="m_Header" use="encoded" namespace="urn:ChestersCopperpotsService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:ChestersCopperpotsService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<soap:header message="s0:m_Header" part="m_Header" use="encoded" namespace="urn:ChestersCopperpotsService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="ChestersCopperpotsService">
<port name="ChestersCopperpotsServiceSoap" binding="s0:ChestersCopperpotsServiceSoap">
<soap:address location="http://localhost:80/ChestersCopperpots/ccSOAP.dll?Handler=Default"/>
</port>
</service>
</definitions>
Full message stack from Azure APIM is:
Informational: ParsingXMLStarted : Started parsing XML
Informational: ParsingXMLComplete : Completed parsing XML
Verbose: WsdlImportRuleVerifyWadl11Schema : WSDL validated against XML Schema
Informational: WsdlPrecheckComplete : Completed WSDL verification. WSDL is considered valid.
Informational: WsdlParsingStarted : Service : Endpoint :
Informational: WsdlIdentification : WsdlVersion: 'Wsdl11' TargetNamespace: 'urn:ChestersCopperpotsServiceSoap'.
Informational: LoadedSchema : Target Namespace: 'urn:ChestersCopperpotsServiceSoap'.
Informational: LoadedSchemas : Loaded '1' schemas.
Informational: LoadedTypes : Loaded '0' types.
Informational: LoadedMessages : Loaded '3' messages.
Informational: LoadedInterfaces : Loaded '1' interfaces.
Informational: LoadedBindings : Loaded '1' bindings.
Informational: LoadedServices : Loaded '1' services.
Informational: WsdlParsingComplete : Parsed 1 operations and 3 messages
Informational: ApiType : Creating SOAP Passthrough API
Informational: APICreated : Name : chesterscopperpotsservice Service Url: http://localhost:80/ChestersCopperpots/ccSOAP.dll?Handler=Default
Informational: XsdParsing : Starting to parse urn:ChestersCopperpotsServiceSoap
Error: Parsing error : Line 17, position 22: Unable to import API from WSDL: Undefined complexType 'http://schemas.xmlsoap.org/soap/encoding/:Array' is used as a base for complex type restriction.
my money is on this part (which in lack of row #, I suspect this is where the error get's triggered). The SOAP-to-REST transformation in APIM only supports "embedded" arrays, whereas yours is referring to another definition ("s0.CMessage" above). Try replacing that bit with
<s:complexType name="GetMessages_return_Array">
<sequence>
<element name="ArrayOfCMessages" type="CMessage" minOccurs="1" maxOccurs="1"/>
</sequence>
</s:complexType>

Shaka packager doesn't encrypt assets

I am just unable to figure out how shaka player is able to decrypt my CENC protected content even though I am providing invalid decryption keys in player config.
player.configure({
drm: {
clearKeys: {
'6FepeJBbmaiozSMs18vPfA==': '6FepeJBbmaiozSMs18vPfA==', // ==> invalid key
'6FepeJBbmaiozSMs18vPfA==': '6FepeJBbmaiozSMs18vPfA==', // ==> invalid key
}
}
})
and here is the arguments given to packager
packager in=video-SD.webm,stream=audio,output=protected_audio.webm,drm_label=AUDIO in=video-HD.
webm,stream=video,output=protected_video_HD.webm,drm_label=HD in=video-SD.webm,stream=video,output=prote
cted_video_SD.webm,drm_label=SD --enable_raw_key_encryption --enable_raw_key_decryption \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519, label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392 \
--base_urls https://s3-eu-west-1.amazonaws.com/dash/ \
--mpd_output h264.mpd
mpd file looks like
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version 72c4797-release-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT5.539000034332275S">
<BaseURL>https://s3-eu-west-1.amazonaws.com/dash/</BaseURL>
<Period id="0">
<AdaptationSet id="0" contentType="audio" lang="en" subsegmentAlignment="true">
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="f3c5e036-1e66-54b2-8f80-49c778b23946">
<cenc:pssh>AAAAVHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAPzxeA2HmZUso+AScd4sjlGq7onHovPVSu9LoakNKml2au6Jx6Lz1UrvS6GpDSppdkAAAAA</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="96897" codecs="vorbis" mimeType="audio/webm" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>protected_audio.webm</BaseURL>
<SegmentBase indexRange="4601-4619" timescale="1000000" presentationTimeOffset="3000">
<Initialization range="0-4600"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="560" height="320" frameRate="1000000/33000" subsegmentAlignment="true" par="7:4">
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="abba271e-8bcf-552b-bd2e-86a434a9a5d9">
<cenc:pssh>AAAAVHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAPzxeA2HmZUso+AScd4sjlGq7onHovPVSu9LoakNKml2au6Jx6Lz1UrvS6GpDSppdkAAAAA</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="553816" codecs="vp8" mimeType="video/webm" sar="1:1">
<BaseURL>protected_video_HD.webm</BaseURL>
<SegmentBase indexRange="336-354" timescale="1000000" presentationTimeOffset="3000">
<Initialization range="0-335"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="2" contentType="video" width="560" height="320" frameRate="1000000/33000" subsegmentAlignment="true" par="7:4">
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="abba271e-8bcf-552b-bd2e-86a434a9a5d9">
<cenc:pssh>AAAAVHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAPzxeA2HmZUso+AScd4sjlGq7onHovPVSu9LoakNKml2au6Jx6Lz1UrvS6GpDSppdkAAAAA</cenc:pssh>
</ContentProtection>
<Representation id="2" bandwidth="561429" codecs="vp09.00.21.08.01.01.01.01.00" mimeType="video/webm" sar="1:1">
<BaseURL>protected_video_SD.webm</BaseURL>
<SegmentBase indexRange="366-384" timescale="1000000" presentationTimeOffset="3000">
<Initialization range="0-365"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>
Either you or someone else asked a similar question on our GitHub page here. It is preferable to ask questions on our GitHub page.
The problem is that asset isn't actually encrypted. It has a clear lead, so the first few seconds aren't actually encrypted. On the GitHub question they explicitly passed --clear-lead 6; but this doesn't pass anything, so Shaka Packager defaults to 10 seconds. This asset is only 6 seconds long, so nothing is encrypted.

how to make http request from xml soap?

I am implementing one of the payment gateway(Advance cash) in my application.Here is the link :
Adv documentaion
According to its documentation I have to made request for transaction. But the request mention in it in xml format.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsm="http://wsm.advcash/">
<soapenv:Header/>
<soapenv:Body>
<wsm:sendMoney>
<arg0>
<apiName>api_name</apiName>
<authenticationToken>token</authenticationToken>
<accountEmail>name#example.com</accountEmail>
</arg0>
<arg1>
<amount>1.00</amount>
<currency>USD</currency>
<email>name#example.com</email>
<note>Some note</note>
<savePaymentTemplate>false</savePaymentTemplate>
</arg1>
</wsm:sendMoney>
</soapenv:Body>
</soapenv:Envelope>
I think it is kind of soap request,I want to know how to request this and what are the parameters I have to send using my node js application using "request" npm module.Please help.
You should use node-soap package. There is a request option which override the request module.
I made a sample, take a look
service.ts:
const service = {
UserService: {
ServicePort: {
getUserById(args) {
const user = { id: args.id, name: faker.name.findName(), email: faker.internet.email() };
return user;
}
}
}
};
service.wsdl:
<definitions name="Service" targetNamespace="http://localhost:8001/get-started/service.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://localhost:8001/get-started/service.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="GetUserByIdInput">
<part name="id" type="xsd:string"></part>
</message>
<message name="GetUserByIdOutput">
<part name="id" type="xsd:string"></part>
<part name="name" type="xsd:string"></part>
<part name="email" type="xsd:string"></part>
</message>
<portType name="ServicePortType">
<operation name="getUserById">
<input message="tns:GetUserByIdInput"/>
<output message="tns:GetUserByIdOutput"></output>
</operation>
</portType>
<binding name="ServiceSoapBinding" type="tns:ServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getUserById">
<soap:operation soapAction="getUserById"/>
<input message="tns:GetUserByIdInput">
<soap:body parts="id" use="literal"/>
</input>
<output message="tns:GetUserByIdOutput">
<soap:body parts="id" use="literal"/>
<soap:body parts="name" use="literal"/>
<soap:body parts="email" use="literal"/>
</output>
</operation>
</binding>
<service name="UserService">
<documentation>Get started service</documentation>
<port name="ServicePort" binding="tns:ServiceSoapBinding">
<soap:address location="http://localhost:8001/get-started"/>
</port>
</service>
</definitions>
request.xml:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://localhost:8001/get-started/service.wsdl">
<soap:Body>
<tns:getUserById>
<id>8104d3c3-de13-432f-b4a0-a62f84f6206a</id>
</tns:getUserById>
</soap:Body>
</soap:Envelope>
server.spec.ts:
it('should get correct result using http request and static xml', async (done: jest.DoneCallback) => {
const xml = fs.readFileSync(path.resolve(__dirname, './static-xml.xml'), 'utf8');
const uuid = '8104d3c3-de13-432f-b4a0-a62f84f6206a';
const options = {
url,
method: 'POST',
body: xml,
headers: {
'Content-Type': 'text/xml;charset=utf-8',
'Accept-Encoding': 'gzip,deflate',
'Content-Length': xml.length
}
};
const rawXml = await request(options);
parser.parseString(rawXml, (err, actualValue) => {
if (err) {
done(err);
}
console.log('actualValue: ', JSON.stringify(actualValue));
expect(actualValue['soap:Envelope']['soap:Body']['tns:getUserByIdResponse']['tns:id']).toBe(uuid);
done();
});
});
The result:
actualValue: {"soap:Envelope":{"$":{"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/","xmlns:tns":"http://localhost:8001/get-started/service.wsdl"},"soap:Body":{"tns:getUserByIdResponse":{"tns:id":"bf0f6172-2f53-4b33-94c8-9ff9ed8fd431","tns:name":"Theo Leannon","tns:email":"Brent.Berge#hotmail.com"}}}}
Here is the demo: https://github.com/mrdulin/nodejs-soap/tree/master/src/get-started

OC 2.0 Fedex shipping method not working

We tried to Fedex shipping method in our opencart website.
It Display the "Error" text.
ERRORERRORcrs691The PurposeOfShipmentType is null, empty or invalid.
The PurposeOfShipmentType is null, empty or invalid.crs1000
Use this xml
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/rate/v13">
<SOAP-ENV:Body>
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>XXXXX</Key>
<Password>XXXXX</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>XXXXX</AccountNumber>
<MeterNumber>XXXXX</MeterNumber>
</ClientDetail>
<TransactionDetail>
<CustomerTransactionId>MY-RATE-REQUEST</CustomerTransactionId>
</TransactionDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>13</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<ReturnTransitAndCommit>true</ReturnTransitAndCommit>
<RequestedShipment>
<ShipTimestamp>2012-10-09T14:28:07.9489435+05:30</ShipTimestamp>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>YOUR_PACKAGING</PackagingType>
<Shipper>
<Address>
<StreetLines>Sardarnagar Main Road, Rajkot</StreetLines>
<City>Rajkot</City>
<StateOrProvinceCode>GJ</StateOrProvinceCode>
<PostalCode>360001</PostalCode>
<CountryCode>IN</CountryCode>
</Address>
</Shipper>
<Recipient>
<Address>
<StreetLines>Radhekrishna App. Main Road , Rajkot</StreetLines>
<City>Bhuj</City>
<StateOrProvinceCode>GJ</StateOrProvinceCode>
<PostalCode>370001</PostalCode>
<CountryCode>IN</CountryCode>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>XXXXX</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<CustomsClearanceDetail>
<DutiesPayment>
<PaymentType>RECIPIENT</PaymentType>
</DutiesPayment>
<DocumentContent>NON_DOCUMENTS</DocumentContent>
<CustomsValue>
<Currency>INR</Currency>
<Amount>299.000000</Amount>
</CustomsValue>
<CommercialInvoice>
<Purpose>NOT_SOLD</Purpose>
</CommercialInvoice>
</CustomsClearanceDetail>
<RateRequestTypes>ACCOUNT</RateRequestTypes>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<SequenceNumber>1</SequenceNumber>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>KG</Units>
<Value>1</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Invalid XML Signature when adding namespace

I'm generating a XML Xades signature. I need to add the namespace http://uri.etsi.org/01903/v1.3.2# in the TAG signature.
If I add this TAG after signing the doc, I get invalid signature error.
I don't know how to add it before, because I only have the TAG Signature after signing.ยด
This is the code to add namespace
void addNamespace(doc)
{
NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
Node a = nl.item(0);
Element sig = (Element)a;
sig.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:etsi","http://uri.etsi.org/01903/v1.3.2#");
}
The code for signature:
signContext = new DOMSignContext(pk, parentElement);
signContext.putNamespacePrefix("http://uri.etsi.org/01903/v1.3.2#","etsi");
XMLSignature signature;
signature.sign(signContext);
addNamespace(doc);
The XML:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-830342">
<ds:SignedInfo Id="SignedInfo-830342">
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>tKDaVHCywRrFbblaDIKZjUviXkI=</ds:DigestValue>
</ds:Reference>
<ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedProperties-830342">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>M/coSDm1tqC4DKkbCyXUP82fB58=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#KeyInfo-830342">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>pInn5xZepngScAKAse0zZPuhyNU=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue Id="SignatureValue843847">
PTJj6kXgDNRwXKQvDH5xr+FF5+naKjAo3bl70Wwlc6MAU2EgMTaCnh7Ml7wvfKvNWbPvTL+5bXYH FlSuC3PsDn2SguQ1vvWm1xI6cZAKh0w4sMiQiS9UDjxIifyZZqNwcZ7uCX2c6K+S7xNQZzcPi5HW oQ+6Pq8vtSZODxN6b0Y=
</ds:SignatureValue>
<ds:KeyInfo Id="KeyInfo-830342">
<ds:X509Data>
<ds:X509Certificate>
MIIDiTCCAnGgAwIBAgIBKjANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQGEwJFUzESMBAGA1UECBMJ QmFyY2Vsb25hMQ8wDQYDVQQKEwZpc2lnbWExFzAVBgNVBAMTDmlzaWdtYSByb290IENBMR8wHQYJ KoZIhvcNAQkBFhBpc2lnbWFAaXNpZ21hLmVzMB4XDTE0MDUzMDA4MjgxOFoXDTE5MDUyOTA4Mjgx OFowgZsxCzAJBgNVBAYTAkVTMRIwEAYDVQQIEwliYXJjZWxvbmExEjAQBgNVBAcTCUJhcmNlbG9u YTEPMA0GA1UEChMGaXNpZ21hMQswCQYDVQQLEwJpdDETMBEGA1UEAxMKRGVtb3MgdXNlcjESMBAG A1UEBRMJMTIzNDU2NzhaMR0wGwYJKoZIhvcNAQkBFg5pbmZvQGlzaWdtYS5lczCBnzANBgkqhkiG 9w0BAQEFAAOBjQAwgYkCgYEAl+AvFwUL16YdzlPT42EMEBhvWQP5Cmt4RXFMKTZ7TXes0y/jT/l1 VF3evNuGI+RZCweUGVqzRWA3z+tV3qbVXuRKtNfXjGvhtG8RTX2SYwqvjDGsnR0XS8Gd1kGUGbeL fOE8vF3q5O2OiN5FF0xMg/0uEw2fZ3P9zONVLsT/A6kCAwEAAaOBiTCBhjAJBgNVHRMEAjAAMAsG A1UdDwQEAwIHgDAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUw HQYDVR0OBBYEFCc/oVSDFtH46U81hILH78cwLnR9MB8GA1UdIwQYMBaAFLIkRa3EwPkvEabba+7h fY4FDjr9MA0GCSqGSIb3DQEBBQUAA4IBAQB1TpQ66zJL+69iooqSQIryzLykWqcXeVeJOAWbGwbP x2P5LVboqXRxj5j9jmlTyqQLRoHLS5BaExq+P+2sPd/BOU2/QV9yrv7uAFkxyQjcMip8eqj1pc0X gqW+JoIkeeqa+UWj+fVQg/YqHsFNgkSoxCf4aPWC2x5X33SH6D8QkXQw4FJcRppfmr4ljsbPmuvV V1uk34I6PTb3gRlVIiTvUWtRaOLQ0lDlFa5bO5rd9nQV7UsK2e7ghXZpUtdW6OAYIuP3ASweOlE1 6z2DiMlYMGJ8Ci/vdcG1eEhVQoV0+z2s78ybJXelTiuxHvuJLPTNk5eoG5zAOAz8oFoQi+51
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
<ds:Object Id="Signature20257-data545881">
<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#"Target="#Signature-830342">
<xades:SignedProperties Id="SignedProperties-830342">
<xades:SignedSignatureProperties>
<xades:SigningTime>2014-07-08T12:40:02+02:00</xades:SigningTime>
<xades:SigningCertificate>
<xades:Cert>
<xades:CertDigest>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>ivK7JSJgkt1YHLuXeUphxagMGcI=</ds:DigestValue>
</xades:CertDigest>
</xades:Cert>
</xades:SigningCertificate>
<xades:SignaturePolicyIdentifier>
<xades:SignaturePolicyId>
<xades:SigPolicyId>
<xades:Identifier>
http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf
</xades:Identifier>
<xades:Description>facturae31</xades:Description>
</xades:SigPolicyId>
<xades:SigPolicyHash>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>Ohixl6upD6av8N7pEvDABhEL6hM=</ds:DigestValue>
</xades:SigPolicyHash>
</xades:SignaturePolicyId>
</xades:SignaturePolicyIdentifier>
<xades:SignerRole>
<xades:ClaimedRoles>
<xades:ClaimedRole>supplier</xades:ClaimedRole>
</xades:ClaimedRoles>
</xades:SignerRole>
</xades:SignedSignatureProperties>
<xades:SignedDataObjectProperties/>
</xades:SignedProperties>
<xades:UnsignedProperties/>
</xades:QualifyingProperties>
</ds:Object>
</ds:Signature>
</note>
I need that namespace will be in the TAG Signature instead of the TAG Object
Namespaces are used to calculate hash value. Canonicalization shoud add them to document (additionally in alphabetical order).
Adding namespaces to signed document obviously will change its hash

Resources