How to put And and OR filter type when RetrieveMultiple query is Fetch Expression - plugins

Please advice how to filter CRM/Model Driven App Unified Client Interface View using below same query expression in RetrieveMultiple plugin when input parameter query is of type Fetch Expression:
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
string[] sourceChannel = new string[] { "Central Bank", "AECB" };
FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression("reopeningcount", ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);
qe.Criteria.AddFilter(filter);
I tried below by taking help from Microsoft documentation as described here:
https://learn.microsoft.com/en-us/powerapps/developer/data-platform/org-service/samples/modify-query-preoperation-stage
But I don't have any idea how to put And and OR filter type in below XML Document.
Any help or guidance would be appreciated a lot.
entityElement.Add(
new XElement("filter",
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value", new XText("Central Bank")),
new XElement("value", new XText("AECB"))
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);

In FetchXml the expression you're trying to write is (see the type='and'):
<filter type='and' >
<condition attribute='sourcechannelidname' operator='not-in' >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute='casetypecode' operator='eq' value='1' >
</filter>
So I think you just need to specify an XAttribute on the "filter" XElement
entityElement.Add(
new XElement("filter",
new XAttribute("type", "and"),
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value", new XText("Central Bank")),
new XElement("value", new XText("AECB"))
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);

XrmToolbox can now parse C# into a fetch expression. Just use the "View" menu and choose "QueryExpression" to get it to pull open the window, then type (or paste) your valid code into it and click "Parse" and it will turn it into FetchXml for you.
You didn't include the full fetchXml query, and I didn't recognize the field names, but I copied it to the OOTB incident query (since I knew it had a casetypecode field) and replaced the field names with the same type. I made them parameters so you can easily replace them with your own params. Here is the code I used:
// Instantiate QueryExpression query
var query = new QueryExpression("incident");
query.TopCount = 50;
// Add all columns to query.ColumnSet
query.ColumnSet.AllColumns = true;
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
string[] sourceChannel = new string[] { "Central Bank", "AECB" };
var stringColName = "ticketnumber";
var intColName = "timezoneruleversionnumber";
var pickColName = "servicestage";
FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression(intColName, ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);
query.Criteria.AddFilter(filter);
and this is the filter it created:
<filter type="and" >
<filter type="or" >
<filter type="and" >
<condition attribute="ticketnumber" operator="not-in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="1" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="2" />
<condition attribute="timezoneruleversionnumber" operator="gt" value="0" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="2" />
<condition attribute="statecode" operator="ne" value="0" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
</filter>
</filter>

Related

Soap request signing

Hello fellow developers,
I have no experience working on soap, saml and xml signing,
I am trying to generate this structure and then add 2 signature tags to it.
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header xmlns:a="http://www.w3.org/2005/08/addressing">
<a:MessageID></a:MessageID>
<a:To env:mustUnderstand="true"></a:To>
<a:Action env:mustUnderstand="true">urn:hl7-org:v3:PRPA_IN201305UV02:CrossGatewayPatientDiscovery</a:Action>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Timestamp wsu:Id="timestamp_ID">
<wsu:Created>2022-10-13T18:18:17.763Z</wsu:Created>
<wsu:Expires>2023-10-13T18:23:17.763Z</wsu:Expires>
</wsu:Timestamp>
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="assertion_ID" IssueInstant="2022-10-13T18:18:17.763Z" Version="2.0">
<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:X509SubjectName"></saml2:Issuer>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#assertion_ID">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue></DigestValue>
</Reference>
</SignedInfo>
<SignatureValue></SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate></X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName"></saml2:NameID>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:holder-of-key">
<saml2:SubjectConfirmationData>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyValue>
<RSAKeyValue>
<Modulus></Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</saml2:SubjectConfirmationData>
</saml2:SubjectConfirmation>
</saml2:Subject>
<saml2:Conditions NotBefore="2022-10-13T18:15:17.763Z" NotOnOrAfter="2022-10-13T18:23:17.763Z">
<saml2:AudienceRestriction>
<saml2:Audience></saml2:Audience>
</saml2:AudienceRestriction>
</saml2:Conditions>
<saml2:AuthnStatement AuthnInstant="2022-10-13T17:55:17.743Z" SessionIndex="1234567890">
<saml2:SubjectLocality Address="10.1.1.144" DNSName="localhost"/>
<saml2:AuthnContext>
<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>
</saml2:AuthnContext>
</saml2:AuthnStatement>
<saml2:AttributeStatement>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:subject-id">
<saml2:AttributeValue>John Doe</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:organization">
<saml2:AttributeValue>Dr. John M Doe, MD Practice</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:organization-id">
<saml2:AttributeValue></saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:nhin:names:saml:homeCommunityId">
<saml2:AttributeValue></saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xacml:2.0:subject:role">
<saml2:AttributeValue>
<Role xmlns="urn:hl7-org:v3" code="112247003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" displayName="Medical doctor" xsi:type="CE"/>
</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:purposeofuse">
<saml2:AttributeValue>
<PurposeOfUse xmlns="urn:hl7-org:v3" code="TREATMENT" codeSystem="2.16.840.1.113883.3.18.7.1" codeSystemName="nhin-purpose" displayName="Treatment" xsi:type="CE"/>
</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xacml:2.0:resource:resource-id">
<saml2:AttributeValue></saml2:AttributeValue>
</saml2:Attribute>
</saml2:AttributeStatement>
</saml2:Assertion>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#timestamp_ID">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue></DigestValue>
</Reference>
</SignedInfo>
<SignatureValue></SignatureValue>
<KeyInfo>
<wsse:SecurityTokenReference xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
<wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID">assertion_ID</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</KeyInfo>
</Signature>
</wsse:Security>
</env:Header>
<env:Body>
<PRPA_IN201305UV02 xmlns="urn:hl7-org:v3" ITSVersion="XML_1.0">
<id extension="126627497759" root="1.3.6.1.4.1.52618.1.3"/>
<creationTime value="20221013181817"/>
<interactionId extension="PRPA_IN201305UV02" root="2.16.840.1.113883.1.6"/>
<processingCode code="P"/>
<processingModeCode code="T"/>
<acceptAckCode code="AL"/>
<receiver typeCode="RCV">
<device classCode="DEV" determinerCode="INSTANCE">
<id root="0.0.0"/>
<telecom value="https://RH-Windows-TMP-b994dba9f85ba908.elb.us-east-1.amazonaws.com:4437/"/>
<asAgent classCode="AGNT">
<representedOrganization classCode="ORG" determinerCode="INSTANCE">
<id root=""/>
</representedOrganization>
</asAgent>
</device>
</receiver>
<sender typeCode="SND">
<device classCode="DEV" determinerCode="INSTANCE">
<id root="1.3.6.1.4.1.52618.1.2"/>
<asAgent classCode="AGNT">
<representedOrganization classCode="ORG" determinerCode="INSTANCE">
<id root="1.3.6.1.4.1.52618.1"/>
</representedOrganization>
</asAgent>
</device>
</sender>
<controlActProcess classCode="CACT" moodCode="EVN">
<code code="PRPA_TE201305UV02" codeSystem="2.16.840.1.113883.1.6"/>
<authorOrPerformer typeCode="AUT">
<assignedDevice classCode="ASSIGNED">
<id root="1.3.6.1.4.1.52618.1.1"/>
</assignedDevice>
</authorOrPerformer>
<queryByParameter>
<queryId extension="126627497760" root="1.3.6.1.4.1.52618.1.3.1"/>
<statusCode code="new"/>
<responseModalityCode code="R"/>
<responsePriorityCode code="I"/>
<parameterList>
<livingSubjectAdministrativeGender>
<value code="M"/>
<semanticsText>LivingSubject.administrativeGender</semanticsText>
</livingSubjectAdministrativeGender>
<livingSubjectBirthTime>
<value value=""/>
<semanticsText>LivingSubject.birthTime</semanticsText>
</livingSubjectBirthTime>
<livingSubjectId>
<value extension="" root="1.3.6.1.4.1.52618.1.1"/>
<semanticsText>LivingSubject.id</semanticsText>
</livingSubjectId>
<livingSubjectName>
<value>
<given></given>
<family>TEST</family>
</value>
<semanticsText>LivingSubject.name</semanticsText>
</livingSubjectName>
<patientAddress>
<value>
<streetAddressLine>Home Dr</streetAddressLine>
<city>Charlotte</city>
<state>NC</state>
<postalCode></postalCode>
<country>US</country>
</value>
<semanticsText>Patient.addr</semanticsText>
</patientAddress>
</parameterList>
</queryByParameter>
</controlActProcess>
</PRPA_IN201305UV02>
</env:Body>
</env:Envelope>
I am using rhino javascript and below is the code
//////////////////////////////////////////////////////////////////////////////////
// Generate our dynamic message values
//
var timestampId = UUIDGenerator.getUUID();
var assertionId = UUIDGenerator.getUUID();
var createdTimestamp = new Date().toISOString();
var expiresTimestamp = new Date((new Date()).getTime() + 10000*10).toISOString();
var samlenvelope="<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">"+
"<env:Header xmlns:a=\"http://www.w3.org/2005/08/addressing\">"+
"<a:MessageID>urn:uuid:32886a29-98ad-4284-b00e-3fe4ded10d16</a:MessageID>"+
"<a:To env:mustUnderstand=\"true\"></a:To>"+
"<a:Action env:mustUnderstand=\"true\">urn:hl7-org:v3:PRPA_IN201305UV02:CrossGatewayPatientDiscovery</a:Action>"+
"<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">"+
"<wsu:Timestamp wsu:Id=\"timestamp_ID\">"+
"<wsu:Created>2022-10-13T18:18:17.763Z</wsu:Created>"+
"<wsu:Expires>2023-10-13T18:23:17.763Z</wsu:Expires>"+
"</wsu:Timestamp>"+
"<saml2:Assertion xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ID=\"assertion_ID\" IssueInstant=\"2022-10-13T18:18:17.763Z\" Version=\"2.0\">"+
"<saml2:Issuer Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:X509SubjectName\"></saml2:Issuer>"+
"<saml2:Subject>"+
"<saml2:NameID Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName\"></saml2:NameID>"+
"<saml2:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:holder-of-key\">"+
"<saml2:SubjectConfirmationData>"+
"<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"+
"<KeyValue>"+
"<RSAKeyValue>"+
"<Modulus></Modulus>"+
"<Exponent>AQAB</Exponent>"+
"</RSAKeyValue>"+
"</KeyValue>"+
"</KeyInfo>"+
"</saml2:SubjectConfirmationData>"+
"</saml2:SubjectConfirmation>"+
"</saml2:Subject>"+
"<saml2:Conditions NotBefore=\"2022-10-13T18:15:17.763Z\" NotOnOrAfter=\"2022-10-13T18:23:17.763Z\">"+
"</saml2:Conditions>"+
"<saml2:AuthnStatement AuthnInstant=\"2022-10-13T17:55:17.743Z\" SessionIndex=\"1234567890\">"+
"<saml2:SubjectLocality Address=\"10.1.1.144\" DNSName=\"localhost\"/>"+
"<saml2:AuthnContext>"+
"<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>"+
"</saml2:AuthnContext>"+
"</saml2:AuthnStatement>"+
"<saml2:AttributeStatement>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:subject-id\">"+
"<saml2:AttributeValue>John Doe</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:organization\">"+
"<saml2:AttributeValue>Dr. John M Doe, MD Practice</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:organization-id\">"+
"<saml2:AttributeValue></saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:nhin:names:saml:homeCommunityId\">"+
"<saml2:AttributeValue></saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xacml:2.0:subject:role\">"+
"<saml2:AttributeValue>"+
"<Role xmlns=\"urn:hl7-org:v3\" code=\"112247003\" codeSystem=\"2.16.840.1.113883.6.96\" codeSystemName=\"SNOMED CT\" displayName=\"Medical doctor\" xsi:type=\"CE\"/>"+
"</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:purposeofuse\">"+
"<saml2:AttributeValue>"+
"<PurposeOfUse xmlns=\"urn:hl7-org:v3\" code=\"TREATMENT\" codeSystem=\"2.16.840.1.113883.3.18.7.1\" codeSystemName=\"nhin-purpose\" displayName=\"Treatment\" xsi:type=\"CE\"/>"+
"</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xacml:2.0:resource:resource-id\">"+
"<saml2:AttributeValue></saml2:AttributeValue>"+
"</saml2:Attribute>"+
"</saml2:AttributeStatement>"+
"</saml2:Assertion>"+
"</wsse:Security>"+
"</env:Header>"+
"<env:Body>"+
"<PRPA_IN201305UV02 xmlns=\"urn:hl7-org:v3\" ITSVersion=\"XML_1.0\">"+
"<id extension=\"126627497759\" root=\"1.3.6.1.4.1.52618.1.3\"/>"+
"<creationTime value=\"20221013181817\"/>"+
"<interactionId extension=\"PRPA_IN201305UV02\" root=\"2.16.840.1.113883.1.6\"/>"+
"<processingCode code=\"P\"/>"+
"<processingModeCode code=\"T\"/>"+
"<acceptAckCode code=\"AL\"/>"+
"<receiver typeCode=\"RCV\">"+
"<device classCode=\"DEV\" determinerCode=\"INSTANCE\">"+
"<id root=\"0.0.0\"/>"+
"<telecom value=\"https://RH-Windows-TMP-b994dba9f85ba908.elb.us-east-1.amazonaws.com:4437/\"/>"+
"<asAgent classCode=\"AGNT\">"+
"<representedOrganization classCode=\"ORG\" determinerCode=\"INSTANCE\">"+
"<id root=\"\"/>"+
"</representedOrganization>"+
"</asAgent>"+
"</device>"+
"</receiver>"+
"<sender typeCode=\"SND\">"+
"<device classCode=\"DEV\" determinerCode=\"INSTANCE\">"+
"<id root=\"1.3.6.1.4.1.52618.1.2\"/>"+
"<asAgent classCode=\"AGNT\">"+
"<representedOrganization classCode=\"ORG\" determinerCode=\"INSTANCE\">"+
"<id root=\"1.3.6.1.4.1.52618.1\"/>"+
"</representedOrganization>"+
"</asAgent>"+
"</device>"+
"</sender>"+
"<controlActProcess classCode=\"CACT\" moodCode=\"EVN\">"+
"<code code=\"PRPA_TE201305UV02\" codeSystem=\"2.16.840.1.113883.1.6\"/>"+
"<authorOrPerformer typeCode=\"AUT\">"+
"<assignedDevice classCode=\"ASSIGNED\">"+
"<id root=\"1.3.6.1.4.1.52618.1.1\"/>"+
"</assignedDevice>"+
"</authorOrPerformer>"+
"<queryByParameter>"+
"<queryId extension=\"\" root=\"1.3.6.1.4.1.52618.1.3.1\"/>"+
"<statusCode code=\"new\"/>"+
"<responseModalityCode code=\"R\"/>"+
"<responsePriorityCode code=\"I\"/>"+
"<parameterList>"+
"<livingSubjectAdministrativeGender>"+
"<value code=\"M\"/>"+
"<semanticsText>LivingSubject.administrativeGender</semanticsText>"+
"</livingSubjectAdministrativeGender>"+
"<livingSubjectBirthTime>"+
"<value value=\"\"/>"+
"<semanticsText>LivingSubject.birthTime</semanticsText>"+
"</livingSubjectBirthTime>"+
"<livingSubjectId>"+
"<value extension=\"\" root=\"1.3.6.1.4.1.52618.1.1\"/>"+
"<semanticsText>LivingSubject.id</semanticsText>"+
"</livingSubjectId>"+
"<livingSubjectName>"+
"<value>"+
"<given></given>"+
"<family>TEST</family>"+
"</value>"+
"<semanticsText>LivingSubject.name</semanticsText>"+
"</livingSubjectName>"+
"<patientAddress>"+
"<value>"+
"<streetAddressLine>Home Dr</streetAddressLine>"+
"<city>Charlotte</city>"+
"<state>NC</state>"+
"<postalCode></postalCode>"+
"<country>US</country>"+
"</value>"+
"<semanticsText>Patient.addr</semanticsText>"+
"</patientAddress>"+
"</parameterList>"+
"</queryByParameter>"+
"</controlActProcess>"+
"</PRPA_IN201305UV02>"+
"</env:Body>"+
"</env:Envelope>"+;
var samlString = new java.lang.String(samlenvelope);
////////////////////////////////////////////////////////////////////////////////////
// Build our XML DOM for signature
//
var documentBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
var document = documentBuilderFactory.newDocumentBuilder().parse(new java.io.ByteArrayInputStream(samlString.getBytes("utf-8")));
////////////////////////////////////////////////////////////////////////////////////
// Configure Digital Signature utilities for required crypto operations
//
var xmlDsigFactory = javax.xml.crypto.dsig.XMLSignatureFactory.getInstance("DOM");
var parameterSpec = new javax.xml.crypto.dsig.spec.ExcC14NParameterSpec();
var reference = xmlDsigFactory.newReference
(
"#assertion_ID",
xmlDsigFactory.newDigestMethod(javax.xml.crypto.dsig.DigestMethod.SHA1, null),
java.util.Collections.singletonList(xmlDsigFactory.newTransform("http://www.w3.org/2001/10/xml-exc-c14n#", parameterSpec)),
null, //type
null //id
)
var signedInfo = xmlDsigFactory.newSignedInfo
(
xmlDsigFactory.newCanonicalizationMethod
(
javax.xml.crypto.dsig.CanonicalizationMethod.EXCLUSIVE,
parameterSpec
),
xmlDsigFactory.newSignatureMethod(javax.xml.crypto.dsig.SignatureMethod.RSA_SHA1, null),
java.util.Collections.singletonList(reference)
)
var reference1 = xmlDsigFactory.newReference
(
"#timestamp_ID",
xmlDsigFactory.newDigestMethod(javax.xml.crypto.dsig.DigestMethod.SHA1, null),
java.util.Collections.singletonList(xmlDsigFactory.newTransform("http://www.w3.org/2001/10/xml-exc-c14n#", parameterSpec)),
null, //type
null //id
)
var signedInfo1 = xmlDsigFactory.newSignedInfo
(
xmlDsigFactory.newCanonicalizationMethod
(
javax.xml.crypto.dsig.CanonicalizationMethod.EXCLUSIVE,
parameterSpec
),
xmlDsigFactory.newSignatureMethod(javax.xml.crypto.dsig.SignatureMethod.RSA_SHA1, null),
java.util.Collections.singletonList(reference1)
)
//////////////////////////////////////////////////////
// Fetch our certificate and key
//
var certificate;
try
{
var inputStream = new java.io.FileInputStream("test.crt");
var certificateFactory = java.security.cert.CertificateFactory.getInstance("X.509");
certificate = certificateFactory.generateCertificate(inputStream);
}
finally
{
if (inputStream != null)
inputStream.close();
}
var privateKey;
var keyFactory = java.security.KeyFactory.getInstance("RSA");
var keySpec = new java.security.spec.PKCS8EncodedKeySpec(java.nio.file.Files.readAllBytes(new java.io.File("private_key.der").toPath()));
privateKey = keyFactory.generatePrivate(keySpec);
////////////////////////////////////////////////////////
// Generate the KeyInfo for our signature
//
var keyInfoFactory = xmlDsigFactory.getKeyInfoFactory();
var x509Content = new java.util.ArrayList();
x509Content.add(certificate);
var x509Data = keyInfoFactory.newX509Data(x509Content);
var keyInfo = keyInfoFactory.newKeyInfo(java.util.Collections.singletonList(x509Data));
var signature = xmlDsigFactory.newXMLSignature(signedInfo, keyInfo);
var dsc = new javax.xml.crypto.dsig.dom.DOMSignContext(privateKey, document.getDocumentElement());
var rootEl = document.getDocumentElement();
rootEl.setIdAttribute("ID",true);
signature.sign(dsc);
var signature1 = xmlDsigFactory.newXMLSignature(signedInfo1, keyInfo1);
var dsc = new javax.xml.crypto.dsig.dom.DOMSignContext(privateKey, document.getDocumentElement());
signature1.sign(dsc);
/*
var newEle=document.createElement("Transform");
newEle.setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#enveloped-signature');
document.getElementsByTagName("Transforms").item(0).appendChild(newEle);*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define any formatting preferences get the signed document as a string
//
var transformerFactory = javax.xml.transform.TransformerFactory.newInstance();
var transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
var stringWriter = new java.io.StringWriter();
transformer.transform(new javax.xml.transform.dom.DOMSource(document), new javax.xml.transform.stream.StreamResult(stringWriter));
channelMap.put("soapMessage", stringWriter.toString());
when I run the code I get this error
Wrapped org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to
reference a node in a context where it does not exist.
Will appreciate your help

Azure Media Services v3 create asset filter returns BadRequest

Azure Media Services v3 create asset filter returns BadRequest.
Both code and manifest are included below. Asset duration is 00:00:26.4330000
Have tried adjusting the tracks, no tracks.
Have tried adjusting the time parameters.
Any ideas on what is wrong?
Is it possible for the API to report more information on what is wrong?
Can a sample be created that shows how to use AssetFilters.CreateOrUpdate with and without track filters?
Code
var timingData = GetManifestTimingData(new Uri(asset.ManifestUrl));
Log.Info($"Timescale: {timingData.TimeScale} Offset: {timingData.TimestampOffset} clip: ( {TimeSpan.FromSeconds(startTimeSec)} - {TimeSpan.FromSeconds(endTimeSec)} ) as ( {TimeSpan.FromSeconds(startTimeSec)} to {TimeSpan.FromSeconds(endTimeSec)} ) {name} ----- {asset.ToAssetInfo()?.hashKey} {asset.Name} -- Manifest: {asset.PlaybackUrl}");
if (startTimeSec >= timingData.AssetDuration.TotalSeconds)
{
Log.Error($"Invalid start time: {startTimeSec} > {timingData.AssetDuration}");
return null;
}
if (endTimeSec >= timingData.AssetDuration.TotalSeconds)
{
endTimeSec = (int)Math.Floor(timingData.AssetDuration.TotalSeconds);
}
var startTimeSpan = timingData.OffSetAsTimeSpan + TimeSpan.FromSeconds(startTimeSec);
var endTimeSpan = timingData.OffSetAsTimeSpan + TimeSpan.FromSeconds(endTimeSec);
double timeScale = timingData.TimeScale ?? TimeSpan.TicksPerSecond;
var scaledStartTime = Convert.ToInt64(Math.Truncate(startTimeSpan.Ticks * (timeScale / TimeSpan.TicksPerSecond)));
var scaledEndTime = Convert.ToInt64(Math.Truncate(endTimeSpan.Ticks * (timeScale / TimeSpan.TicksPerSecond)));
var range = new PresentationTimeRange(scaledStartTime, scaledEndTime, 9223372036854775807, 0, (long)timeScale, false);
var tracks = new List<FilterTrackSelection>
{
new FilterTrackSelection(new List<FilterTrackPropertyCondition>
{
new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Audio", FilterTrackPropertyCompareOperation.Equal),
}),
new FilterTrackSelection(new List<FilterTrackPropertyCondition>
{
new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Video", FilterTrackPropertyCompareOperation.Equal),
}),
};
var firstQuality = new FirstQuality(128000);
var filterParams = new AssetFilter(null, name, FilterType, range, firstQuality, tracks);
var filter = _client.AssetFilters.CreateOrUpdate(ResourceGroup, AccountName, asset.Id, name, filterParams);
if (filter == null)
{
Log.Warn($"Failed to create filter {name} in {asset}");
return null;
}
return filter;
Manifest
<SmoothStreamingMedia MajorVersion="2" MinorVersion="2" Duration="264333333" TimeScale="10000000">
<StreamIndex Chunks="13" Type="video" Url="QualityLevels({bitrate})/Fragments(video={start time})" QualityLevels="1">
<QualityLevel Index="0" Bitrate="770760" FourCC="H264" MaxWidth="1280" MaxHeight="720" CodecPrivateData="000000016764001FACD9405005BA10000003001000000303C0F18319600000000168EBECB22C" />
<c t="0" d="20333333" r="2" />
<c d="20333334" />
<c d="20333333" r="2" />
<c d="20333334" />
<c d="20333333" r="2" />
<c d="20333334" />
<c d="20333333" r="2" />
<c d="20333334" />
<c d="20333333" />
</StreamIndex>
<StreamIndex Chunks="14" Type="audio" Url="QualityLevels({bitrate})/Fragments(aac_UND_2_127999={start time})" QualityLevels="1" Name="aac_UND_2_127999">
<QualityLevel AudioTag="255" Index="0" BitsPerSample="16" Bitrate="127999" FourCC="AACL" CodecPrivateData="1190" Channels="2" PacketSize="4" SamplingRate="48000" />
<c t="0" d="20053333" r="2" />
<c d="20053334" />
<c d="20053333" r="2" />
<c d="20053334" />
<c d="20053333" r="2" />
<c d="20053334" />
<c d="20053333" r="2" />
<c d="20053334" />
<c d="20053333" />
<c d="3626667" />
</StreamIndex>
<Protection>
<ProtectionHeader SystemID="B47B251A-2409-4B42-958E-08DBAE7B4EE9">
<ContentProtection schemeIdUri="urn:mpeg:dash:sea:2012" xmlns:sea="urn:mpeg:dash:schema:sea:2012">
<sea:SegmentEncryption schemeIdUri="urn:mpeg:dash:sea:aes128-cbc:2013" />
<sea:KeySystem keySystemUri="urn:mpeg:dash:sea:keysys:http:2013" />
<sea:CryptoPeriod IV="0xF6BCAD06C97D0FEC81B702C86183355B" keyUriTemplate="https://testurstream.keydelivery.westus.media.azure.net?kid=d6c1f008-d43f-4c60-926f-76ba613b7b4b" />
</ContentProtection>
</ProtectionHeader>
</Protection>
</SmoothStreamingMedia>
There was a known bug that we hit with Asset Filters that was fixed and rolled out to production now. Looks like you may have hit the same bug. The team is working on also fixing this issue in the .NET SDK and rolling it out.
For now, can you first delete any and all old filters created in v3 API. To fix the issue, you need to remove all old asset and global filters first from this account. We had a versioning mis-match on the filters when we moved from preview to GA that caused a mismatch (and thus the error message you are seeing.) You should be able to get a more detailed error message also if you look at the stacktrace. It typically would show a version conflict issue. Let us know what you see in the details of the error.
Carlos,
Looking at this today for you. Sorry for delay.
I'm using the Postman collection just to see what is going on with the .NET SDK exactly.
Looks like the following filer works fine. I think that the issue you are getting is related to the line of code that creates the new PresentationTimeRange. The values for presentaitonWindowDuration and liveBackoffDuration are not needed for a VOD filter. They are only used for live filters. Try using the following.
new PresentationTimeRange(scaledStartTime, scaledEndTime, null, null, (long)timeScale, null);
{
"properties": {
"presentationTimeRange": {
"startTimestamp": 0,
"endTimestamp": 264333333,
"presentationWindowDuration": null,
"liveBackoffDuration": null,
"timescale": 10000000,
"forceEndTimestamp": null
},
"tracks": [{
"trackSelections": [{
"property": "Type",
"operation": "Equal",
"value": "Video"
},
{
"property": "Type",
"operation": "Equal",
"value": "Audio"
}
]
}]
}
}
I'll double check to see if this is an issue when I run it through the .NET SDK.
I think that our issue here may be that the values for presentationTimeRange are all marked as "REQUIRED" in the current Swagger file here:
https://github.com/Azure/azure-rest-api-specs/blob/dec75495352902ebb6393d42c50465b6195f239d/specification/mediaservices/resource-manager/Microsoft.Media/stable/2018-07-01/AccountFilters.json#L63

Expected behavior of the renderer for superscripts and subscripts in Word Open XML

It looks like ECMA specification for Word Open XML doesn't specify how to render "runs" with vertAlign attribute. Is there a document describing the expected behavior:
What font size to use for superscripts and subscripts?
For how much to shift the superscript/subscript text relatively to the baseline?
Just for reference, here's a document.xml generated by MS Word for a trivial document containing text "X²" (XML namespaces are omitted for brevity):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document>
<w:body>
<w:p w14:paraId="4B8ED8F1" w14:textId="3891D3E1"
w:rsidR="00CE1223" w:rsidRDefault="00886D56">
<w:r>
<w:t>X</w:t>
</w:r>
<w:r w:rsidRPr="00886D56">
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
<w:t>2</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
<w:sectPr w:rsidR="00CE1223">
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"
w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>
The RunProperties elements has following two child elements which can be used to set the position and the font of a Run which has a VerticalTextAlignment:
The RunFonts element which can be used to set the type of font
The Position element which can be used to lower or raise the the run in relation to its default baseline.
Using these elements you can create a run which is in superscript and has an adjusted font:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
FontSize fontSize1 = new FontSize(){ Val = "48" };
VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment(){ Val = VerticalPositionValues.Superscript };
runProperties1.Append(runFonts1);
runProperties1.Append(fontSize1);
runProperties1.Append(verticalTextAlignment1);
return runProperties1;
}
This will output the follwing openxml:
<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:sz w:val="48" />
<w:vertAlign w:val="superscript" />
</w:rPr>
And you can shift the vertical aligned run using these elements:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
Position position1 = new Position(){ Val = "-10" };
FontSize fontSize1 = new FontSize(){ Val = "48" };
VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment(){ Val = VerticalPositionValues.Superscript };
runProperties1.Append(runFonts1);
runProperties1.Append(position1);
runProperties1.Append(fontSize1);
runProperties1.Append(verticalTextAlignment1);
return runProperties1;
}
Generating the follwing openXML:
<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:position w:val="-10" />
<w:sz w:val="48" />
<w:vertAlign w:val="superscript" />
</w:rPr>
Depending on the value that you assign to the position element the run will be raised or lowered in relation to its baseline:
Positve => Raised
Negative => Lowered

KSOAP2 complex request property not being seen

I'm having a problem sending a complex SOAP request to a third-party company server (server can have no changes) from an android device. I'm using KSOAP2 library and one of the properties is missing (server is giving an error which occurs when klausimai is null. Also the same namespace in my request is repeated multiple times when KSOAP2 generates the XML, since I pass a lot of PropertyInfo. My question is, why could the server see other properties (it would also give an error about the null ones) But doesn't see klausimai ?
Sample request XML for WS given by server company
?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<teiktiTemineAtaskaita xmlns="http://tempuri.org/">
<userName>apps</userName>
<password>mob2015*</password>
<uzduotiesNr>24287</uzduotiesNr>
<inspektavimas xmlns:a="http://schemas.datacontract.org/2004/07/DssisMP" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:apsilankymuObjekteSkaicius i:nil="true" />
<a:atstovai i:nil="true" />
<a:darbdavioBuveinesAdresas i:nil="true" />
<a:darbdavioGimimoData i:nil="true" />
<a:darbdavioKodas>110871120</a:darbdavioKodas>
<a:darbdavioLytis i:nil="true" />
<a:darbdavioPagrindineEkonomineVeikla i:nil="true" />
<a:darbdavioPavadinimas i:nil="true" />
<a:darbdavioPavarde i:nil="true" />
<a:darbdavioTipas i:nil="true" />
<a:darbdavioVardas i:nil="true" />
<a:inspektavimoNr>11112245</a:inspektavimoNr>
<a:inspektavimoPradzia>2015-07-23T00:00:00+03:00</a:inspektavimoPradzia>
<a:inspektavimoTiksloKodas>111</a:inspektavimoTiksloKodas>
<a:institucijos i:nil="true" />
<a:savivaldybesKodas i:nil="true" />
<a:temineAtaskaita>
<a:klausimai>
<a:TAKlausimas>
<a:atsakymas>2</a:atsakymas>
<a:eilNr>1.</a:eilNr>
<a:klausimas i:nil="true" />
<a:kodas>1000</a:kodas>
<a:komentaras i:nil="true" />
</a:TAKlausimas>
<a:TAKlausimas>
<a:atsakymas>1</a:atsakymas>
<a:eilNr>1.1.</a:eilNr>
<a:klausimas i:nil="true" />
<a:kodas>1001</a:kodas>
<a:komentaras i:nil="true" />
</a:TAKlausimas>
<a:TAKlausimas>
<a:atsakymas>3</a:atsakymas>
<a:eilNr>2.</a:eilNr>
<a:klausimas i:nil="true" />
<a:kodas>1002</a:kodas>
<a:komentaras i:nil="true" />
</a:TAKlausimas>
</a:klausimai>
<a:nr>BIOCIDŲ PRIEŽIŪRA-0050-0007</a:nr>
<a:rekomendacijos i:nil="true" />
<a:surasymoData>2015-07-23T00:00:00+03:00</a:surasymoData>
<a:tipas>9</a:tipas>
</a:temineAtaskaita>
<a:tikrintaEkonomineVeikla i:nil="true" />
<a:tikrintaNakti i:nil="true" />
<a:tikrintasObjektas i:nil="true" />
<a:tikrintoObjektoAdresas i:nil="true" />
<a:tikrintoObjektoPavadinimas i:nil="true" />
<a:vadovoAsmensKodas i:nil="true" />
<a:vadovoGimimoData i:nil="true" />
<a:vadovoLytis i:nil="true" />
<a:vadovoPareigos i:nil="true" />
<a:vadovoPavarde i:nil="true" />
<a:vadovoVardas i:nil="true" />
</inspektavimas>
</teiktiTemineAtaskaita>
</s:Body>
</s:Envelope>
My HTTPTransport request dump XML generated by KSOAP2
<?xml version="1.0" encoding="UTF-8"?>
<v:Envelope xmlns:v="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<v:Header />
<v:Body>
<teiktiTemineAtaskaita xmlns="http://tempuri.org/">
<userName>apps</userName>
<password>mob2015*</password>
<uzduotiesNr>212855</uzduotiesNr>
<n0:inspektavimas xmlns:n0="http://tempuri.org/">
<inspektavimoNr i:null="true" />
<n1:inspektavimoPradzia xmlns:n1="http://schemas.datacontract.org/2004/07/DssisMP" i:type="d:dateTime">2015-07-26T21:00:00.000Z</n1:inspektavimoPradzia>
<inspektavimoTiksloKodas>1101</inspektavimoTiksloKodas>
<darbdavioKodas>120163917</darbdavioKodas>
<darbdavioPavadinimas>Statybos ir remonto uždaroji akcinė bendrovė "RISTATYBA"</darbdavioPavadinimas>
<darbdavioTipas>1</darbdavioTipas>
<darbdavioBuveinesAdresas i:null="true" />
<darbdavioPagrindineEkonomineVeikla i:null="true" />
<vadovoAsmensKodas>721788222</vadovoAsmensKodas>
<vadovoVardas>tvt</vadovoVardas>
<vadovoPavarde>gtvt</vadovoPavarde>
<vadovoPareigos>5</vadovoPareigos>
<n2:vadovoGimimoDiena xmlns:n2="http://schemas.datacontract.org/2004/07/DssisMP" i:type="d:dateTime">2015-07-22T21:00:00.000Z</n2:vadovoGimimoDiena>
<vadovoLytis>0</vadovoLytis>
<tikrintasObjektas>3</tikrintasObjektas>
<tikrintoObjektoPavadinimas i:null="true" />
<tikrintoObjektoAdresas i:null="true" />
<savivaldybesKodas>46</savivaldybesKodas>
<tikrintaEkonomineVeikla i:null="true" />
<apsilankymuObjekteSkaicius i:null="true" />
<tikrintaNakti>0</tikrintaNakti>
<n3:temineAtaskaita xmlns:n3="http://schemas.datacontract.org/2004/07/DssisMP">
<n3:nr i:null="true" />
<n3:tipas i:type="d:int">18</n3:tipas>
<n3:surasymoData i:type="d:dateTime">2015-07-22T09:53:59.822Z</n3:surasymoData>
<n3:klausimai>
<n3:TAKlausimas>
<n3:kodas i:type="d:string">3183</n3:kodas>
<n3:eilNr i:type="d:string">1.1.</n3:eilNr>
<n3:klausimas i:null="true" />
<n3:atsakymas i:type="d:int">1</n3:atsakymas>
<n3:komentaras i:null="true" />
</n3:TAKlausimas>
<n3:TAKlausimas>
<n3:kodas i:type="d:string">3184</n3:kodas>
<n3:eilNr i:type="d:string">1.1.1.</n3:eilNr>
<n3:klausimas i:null="true" />
<n3:atsakymas i:type="d:int">2</n3:atsakymas>
<n3:komentaras i:null="true" />
</n3:TAKlausimas>
</n3:klausimai>
<n3:rekomendacijos i:type="d:string">Gyghugyb</n3:rekomendacijos>
</n3:temineAtaskaita>
</n0:inspektavimas>
</teiktiTemineAtaskaita>
</v:Body>
</v:Envelope>
My Java code for request creation
List<Questionnaire> questionnaireList = new ArrayList<>();
String METHOD_NAME = "teiktiTemineAtaskaita";
String SOAP_ACTION = "http://tempuri.org/IDssisMP/" + METHOD_NAME;
String A_NAMESPACE = "http://schemas.datacontract.org/2004/07/DssisMP";
String I_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
String NAMESPACE = "http://tempuri.org/";
String URL = "http://dvs/dssis_ws_test/DssisMP.svc";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
UserInfo userInfo = UserInfo.getAll().get(0);
request.addProperty("userName", userInfo.getUserName());
request.addProperty("password", userInfo.getPassword());
request.addProperty("uzduotiesNr", taskId);
CompanyInfo ci = CompanyInfo.getByTaskCompanyId(taskId, companyId);
if (ci == null) {
sendResponseFailed(responseHandler);
//starter validation
} else {
//adding all the non-complex properties
SoapObject inspektavimas = new SoapObject(NAMESPACE, "inspektavimas");
if (ci.getInspectationId() != 0) {
inspektavimas.addProperty("inspektavimoNr", ci.getInspectationId());
} else {
inspektavimas.addProperty("inspektavimoNr", null);
}
if (ci.getDateInspectation() != null) {
PropertyInfo p = new PropertyInfo();
p.setNamespace(A_NAMESPACE);
p.setName("inspektavimoPradzia");
p.setType(MarshalDate.class);
p.setValue(ci.getDateInspectation());
inspektavimas.addProperty(p);
} else {
sendResponseFailed(responseHandler);
}
if (ci.getGoalId() != 0) {
inspektavimas.addProperty("inspektavimoTiksloKodas", ci.getGoalId());
} else {
sendResponseFailed(responseHandler);
}
if (ci.getObjectName() != null) {
inspektavimas.addProperty("tikrintoObjektoPavadinimas", ci.getObjectName());
} else { inspektavimas.addProperty("tikrintoObjektoPavadinimas", null);
}
if (ci.getObjectAddress() != null) {
inspektavimas.addProperty("tikrintoObjektoAdresas", ci.getObjectAddress());
} else {
inspektavimas.addProperty("tikrintoObjektoAdresas", null);
}
//...
SoapObject soTemineAtaskaita = new SoapObject(A_NAMESPACE, "temineAtaskaita");
TemineAtaskaita temineAtaskaita = TemineAtaskaita.getByTaskCompanyThemeCode(taskId, companyId, themeCode);
PropertyInfo p = new PropertyInfo();
p.setNamespace(A_NAMESPACE);
p.setName("nr");
if (temineAtaskaita != null && temineAtaskaita.getAtaskaitosNr() != null) {
p.setValue(temineAtaskaita.getAtaskaitosNr());
soTemineAtaskaita.addProperty(p);
} else {
p.setValue(null);
soTemineAtaskaita.addProperty(p);
}
Theme theme = Theme.getByTaskCompanyThemeCode(taskId, companyId, themeCode);
if (theme != null) {
PropertyInfo pType = new PropertyInfo();
pType.setNamespace(A_NAMESPACE);
pType.setName("tipas");
pType.setValue(theme.getThemeCode());
soTemineAtaskaita.addProperty(pType);
PropertyInfo pDate = new PropertyInfo();
pDate.setNamespace(A_NAMESPACE);
pDate.setName("surasymoData");
pDate.setValue(theme.getDate());
pDate.setType(MarshalDate.class);
soTemineAtaskaita.addProperty(pDate);
}
//adding klausimai property which is not seen
SoapObject klausimai = new SoapObject(A_NAMESPACE, "klausimai");
List <Answer> answers = Answer.getByTaskCompanyThemeCode(taskId, companyId, themeCode);
for (Answer answer : answers) {
SoapObject soTAKlausimas = new SoapObject(A_NAMESPACE, "TAKlausimas");
PropertyInfo pCode = new PropertyInfo();
pCode.setNamespace(A_NAMESPACE);
pCode.setName("kodas");
pCode.setValue(answer.getQuestionId());
soTAKlausimas.addProperty(pCode);
Questionnaire questionnaire = Questionnaire.getById(answer.getQuestionId()).get(0);
PropertyInfo pEilNr = new PropertyInfo();
pEilNr.setNamespace(A_NAMESPACE);
pEilNr.setName("eilNr");
pEilNr.setValue(questionnaire.getPosition());
soTAKlausimas.addProperty(pEilNr);
PropertyInfo pKlausimas = new PropertyInfo();
pKlausimas.setNamespace(A_NAMESPACE);
pKlausimas.setName("klausimas");
pKlausimas.setValue(null);
soTAKlausimas.addProperty(pKlausimas);
PropertyInfo pAnswer = new PropertyInfo();
pAnswer.setNamespace(A_NAMESPACE);
pAnswer.setName("atsakymas");
pAnswer.setValue(questionnaire.getPosition());
if (answer.getAnswer() == QuestionItem.STATUS.YES.ordinal())
pAnswer.setValue(1);
else if (answer.getAnswer() == QuestionItem.STATUS.NO.ordinal())
pAnswer.setValue(2);
else if (answer.getAnswer() == QuestionItem.STATUS.UNKNOWN.ordinal())
pAnswer.setValue(3);
else if (answer.getAnswer() == QuestionItem.STATUS.PLAIN.ordinal())
pAnswer.setValue(null);
soTAKlausimas.addProperty(pAnswer);
PropertyInfo pComment = new PropertyInfo();
pComment.setNamespace(A_NAMESPACE);
pComment.setName("komentaras");
if (answer.getComment() != null && !answer.getComment().replace(" ", "").replace(" ", "").isEmpty()) {
pComment.setValue(answer.getComment());
} else {
pComment.setValue(null);
}
soTAKlausimas.addProperty(pComment);
klausimai.addSoapObject(soTAKlausimas);
}
soTemineAtaskaita.addSoapObject(klausimai);
if (theme != null) {
PropertyInfo pSuggestions = new PropertyInfo();
pSuggestions.setNamespace(A_NAMESPACE);
pSuggestions.setName("rekomendacijos");
if (theme.getSuggestions() != null && !theme.getSuggestions().replace(" ", "").replace(" ", "").isEmpty()) {
pSuggestions.setValue(theme.getSuggestions());
} else {
pSuggestions.setValue(null);
}
soTemineAtaskaita.addProperty(pSuggestions);
}
inspektavimas.addSoapObject(soTemineAtaskaita);
request.addSoapObject(inspektavimas);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setAddAdornments(false);
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);
new MarshalDate().register(envelope);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 45 * 1000);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
final SoapObject response = (SoapObject) envelope.getResponse();
****//...****
}
Well as it turns out, I managed to work together with server company, and the problem was ordering inside temineAtaskaita tag. klausimai property should have been the first property to give, althought outside in inspektavimas tag, ordering is not important and that is confusing.
Other problem now occurs is that, everything inside inspektavimas is null because the properties have no namespace. And adding them as PropertyInfo gives a lot of repeated namespaces (n0, n1,...,n20) in XML request Dump and server doesn't handle it. But this is another problem.

Quartz.NET scheduling

I am new to this Quartz.NET thing and I have some questions about it cause it don't seem to work as I want to.
Question 1: I am defining simple IJobDetail and ITrigger. [SOLVED]
NameValueCollection config = ConfigurationManager.GetSection("quartz") as NameValueCollection;
ISchedulerFactory schedFact = new StdSchedulerFactory(config);
IScheduler scheduler = schedFact.GetScheduler();
try
{
scheduler.Start();
IJobDetail job = JobBuilder.Create<HelloJobTestScheduling>()
.WithIdentity("job1", "group1")
.Build();
DateTimeOffset endDate = DateTime.Now.AddMinutes(5);
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(10)
.WithRepeatCount(2))
.EndAt(endDate)
.Build();
scheduler.ScheduleJob(job, trigger);
}
catch(SchedulerException se)
{
Console.WriteLine(se);
}
finally
{
scheduler.Shutdown();
}
HelloJobTestScheduling
public void Execute(IJobExecutionContext context)
{
JobKey key = context.JobDetail.Key;
JobDataMap dataMap = context.JobDetail.JobDataMap;
string connectionString = #"Data Source=localhost\dejan;Initial Catalog=QuartzTest;Integrated Security=True";
string query = "INSERT INTO test (id, datetime) " +
"VALUES (#id, #datetime) ";
// create connection and command
using (SqlConnection cn = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand(query, cn))
{
// define parameters and their values
cmd.Parameters.Add("#id", SqlDbType.Int).Value = "1";
cmd.Parameters.Add("#datetime", SqlDbType.DateTime).Value = DateTime.Now;
// open connection, execute INSERT, close connection
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
}
App.config
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<quartz>
<add key="quartz.scheduler.instanceName" value="MyScheduler" />
<add key="quartz.scheduler.instanceId" value="AUTO" />
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz"/>
<add key="quartz.threadPool.threadCount" value="30"/>
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.dataSource.default.connectionString" value="Data Source=localhost\dejan;Initial Catalog=QuartzTest;Integrated Security=True" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.clustered" value="false" />
<!--<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />-->
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
<add key="quartz.jobStore.useProperties" value="false" />
</quartz>
What this job actually does in reality is this: inserting only one row in the database, and after that it won't do anything. It waits to the .endAt and shows in console that the scheduler is closed. What is wrong with my code?
Note: I have all the required database tables for the scheduler to work in the background.
Question 2: Why this CRON is not recognized?
.WithCronSchedule("0 1 0 ? * ?")
Visual Studio error says:
'?' can only be specified for Day-of-Month -OR- Day-of-Week.
Cron expressions in Quartz.Net are made up of 7 sub-expressions:
Seconds
Minutes
Hours
Day-of-Month
Month
Day-of-Week
Year (optional field)
The last one is optional.
Your cron expression is not valid.
If you want to run to execute something every minute the right one is: 0 0/1 * 1/1 * ? *
I would advice you to use this tool to generate your cron expressions.
It's easier.
Question 1 is solved. Just a short note, my mistake was that I close the scheduler too early in finally. If I comment that lane, everything works good.
But, I still need help about Question 2.