baj bureau of justice assistance risstech risstech rissapps implementation of gjxdm through...

19
BA J Bureau of Justice Assistance RISS RISSTech RISSTech RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

Post on 19-Dec-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

BAJ Bureau ofJustice Assistance

RISS

RISSTechRISSTech

RISSTechRISSTech

RISSApps Implementation of GJXDM through Microsoft Visual Studio

Page 2: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Content Advisory!

This presentation is extremely technical, i.e., geeky to the This presentation is extremely technical, i.e., geeky to the core.core.

Listening by non-geeks, or those geeks who do not program Listening by non-geeks, or those geeks who do not program in the Microsoft Visual Studio .NET world, may cause in the Microsoft Visual Studio .NET world, may cause drowsiness, head-nodding, and eye-glazing, and may impair drowsiness, head-nodding, and eye-glazing, and may impair your ability to drive or operate heavy machinery.your ability to drive or operate heavy machinery.

This presentation isn’t about best practices or standards, but This presentation isn’t about best practices or standards, but how RISS has architected its applications.how RISS has architected its applications.

And please…And please…

Feel FREE to interrupt with questions!Feel FREE to interrupt with questions!

Page 3: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Technical Architecture of RISSApps

Criminal Intelligence and Pointer Information systemCriminal Intelligence and Pointer Information system Both a data repository and an exchange clearinghouseBoth a data repository and an exchange clearinghouse SQL Server Database for data storageSQL Server Database for data storage .NET middleware (DLLs).NET middleware (DLLs) Multiple interfaces for user interaction and information Multiple interfaces for user interaction and information

exchangeexchange Web/Windows application interfaces for usersWeb/Windows application interfaces for users Windows application for bulk upload of dataWindows application for bulk upload of data Data exchange interfacesData exchange interfaces

SQL Server interfaceSQL Server interface RISSDES web service (RDD/GJXDM 2 compliant)RISSDES web service (RDD/GJXDM 2 compliant) RISSDES 2.0 web service (GJXDM 3 compliant)RISSDES 2.0 web service (GJXDM 3 compliant) Custom gateway interfaces to CSII and CISACustom gateway interfaces to CSII and CISA

Page 4: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Technical Architecture of RISSApps – Middleware (Riss.dll)

Middleware provides single implementation for Middleware provides single implementation for Officer, Subject, Organization, etc.Officer, Subject, Organization, etc.

Purpose is to allow information to be used in a Purpose is to allow information to be used in a generic manner:generic manner: Interaction with userInteraction with user Exchange to and from another systemExchange to and from another system Audit of internal and external user actionsAudit of internal and external user actions Compliance with system-wide business rulesCompliance with system-wide business rules Allows code to be written that is applicable to all Allows code to be written that is applicable to all

facets of the systemfacets of the system

Page 5: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Technical Architecture of RISSApps – Web services (RISSDES 1 & 2)

Web service created for specific exchangeWeb service created for specific exchange Web service consumes classes compatible with GJXDM Web service consumes classes compatible with GJXDM

implementation schemaimplementation schema Web service is simply a conversion from GJXDM classes to Web service is simply a conversion from GJXDM classes to

middleware classes and vice versamiddleware classes and vice versa Web service providing the conversion point allows exchange-Web service providing the conversion point allows exchange-

specific information to be processed and passed to the middleware specific information to be processed and passed to the middleware classes or returned as the result of the web serviceclasses or returned as the result of the web service

Creating implicit operators will allow simpler programming:Creating implicit operators will allow simpler programming:

public static implicit operator public static implicit operator GJXDMClass(BaseClass baseClass){…}GJXDMClass(BaseClass baseClass){…}

allows you to in code do:allows you to in code do:

BaseClass MyBaseClass;BaseClass MyBaseClass;GJXDMClass MyClass = MyBaseClass;GJXDMClass MyClass = MyBaseClass;

Page 6: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Technical Architecture of RISSApps – Web services (RISSDES 1 & 2)

RISSDES 1 passes data as strings and is validated RISSDES 1 passes data as strings and is validated within codewithin code

RISSDES 2 uses strongly-typed classes, i.e., a RISSDES 2 uses strongly-typed classes, i.e., a PersonGivenName datatype is expected at the PersonGivenName datatype is expected at the appropriate node within a Subject elementappropriate node within a Subject element

Strongly-typed version generates more specific Strongly-typed version generates more specific WSDL, therefore is more useable as a web WSDL, therefore is more useable as a web reference within Visual Studio .NETreference within Visual Studio .NET

String data provides much simpler WSDL, but String data provides much simpler WSDL, but requires more documentation and lacks automatic requires more documentation and lacks automatic validationvalidation

Page 7: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Technical Architecture of RISSApps – Exchange mechanisms

(Riss.DataExchange.[Specific].dll)

Specific exchanges done through implementation in Specific exchanges done through implementation in its own DLLits own DLL

Internal classes created to consume web service, Internal classes created to consume web service, i.e., Riss.DataExchange.GJXDM is the DLL i.e., Riss.DataExchange.GJXDM is the DLL frontend to RISSDES2 web service that is used by frontend to RISSDES2 web service that is used by Riss.dllRiss.dll

Page 8: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Usage Example: User requests intel search data from external systems

Application accepts and validates user input, audits request, Application accepts and validates user input, audits request, and creates base request objectand creates base request object

Base request object creates exchange-specific objects for Base request object creates exchange-specific objects for each queried systemeach queried system

Exchange-specific objects receive connection information Exchange-specific objects receive connection information (web service URL, database connection string, etc.)(web service URL, database connection string, etc.)

Exchange-specific objects appropriately format IntelRequestExchange-specific objects appropriately format IntelRequest Exchange-specific objects request data from sourceExchange-specific objects request data from source Exchange-specific objects receive responsesExchange-specific objects receive responses Base request object formats results for userBase request object formats results for user

Page 9: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Usage Example: Intel search request from external system

Web service accepts and validates request from external Web service accepts and validates request from external systemsystem

Web service creates exchange-specific request objectWeb service creates exchange-specific request object Exchange-specific request object converted to base objectExchange-specific request object converted to base object Base object asked to query data sourceBase object asked to query data source Source-specific object created with connection informationSource-specific object created with connection information Source-specific object formats request for the sourceSource-specific object formats request for the source Source-specific object requests dataSource-specific object requests data Source-specific object returns data to base objectSource-specific object returns data to base object Base object passes data to exchange-specific request objectBase object passes data to exchange-specific request object Web service returns XML generated from exchange-specific Web service returns XML generated from exchange-specific

request objectrequest object

Page 10: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Generating Classes from Schemas

Microsoft supplies xsd.exe with Visual Studio to create Microsoft supplies xsd.exe with Visual Studio to create classes from schemas (among other things)classes from schemas (among other things)

Due to proxying of code tables, some special considerations Due to proxying of code tables, some special considerations required to use xsd.exe on GJXDM subset schemas:required to use xsd.exe on GJXDM subset schemas: Doesn’t like relative directory references, i.e., ..\, in imported Doesn’t like relative directory references, i.e., ..\, in imported

namespaces of the schema you are usingnamespaces of the schema you are using These references in <xsd:import> elements of the GJXDM These references in <xsd:import> elements of the GJXDM

schema need to be updatedschema need to be updated It is OK to leave these in the proxy schemas, i.e., schemas in It is OK to leave these in the proxy schemas, i.e., schemas in

jxdm/3.0.x/proxy/<code source>/<version> subdirectoriesjxdm/3.0.x/proxy/<code source>/<version> subdirectories Need to include all proxy, code source, subset, and Need to include all proxy, code source, subset, and

implementation schemas in the command lineimplementation schemas in the command line

Page 11: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Generating Classes from Schemas

Pay attention to the help file for the xsd command!Pay attention to the help file for the xsd command! Format for what we are needing to do:Format for what we are needing to do:

xsd <schema>.xsd /classes /e:<element> xsd <schema>.xsd /classes /e:<element> /n:<.NET namespace>/n:<.NET namespace>

For example:For example:

xsd xsd.xsd usps_states\1.0\usps_states.xsd xsd xsd.xsd usps_states\1.0\usps_states.xsd usps_states.xsd jxdm.xsd rissdes_2_0.xsd /c usps_states.xsd jxdm.xsd rissdes_2_0.xsd /c /e:SearchRequest /n:Riss.DataExchange.GJXDM/e:SearchRequest /n:Riss.DataExchange.GJXDM

would process the proxy schema and base schema for would process the proxy schema and base schema for usps_states, jxdm (the subset schema), and rissdes_2_0 (the usps_states, jxdm (the subset schema), and rissdes_2_0 (the extension schema) and generate classes for the extension schema) and generate classes for the SearchRequest element in the Riss.DataExchange.GJXDM SearchRequest element in the Riss.DataExchange.GJXDM namespacenamespace

Page 12: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Creating Inherited Classes to work with GJXDM Data

Problem:Problem: You want to use the ability of the xsd.exe tool to You want to use the ability of the xsd.exe tool to

generate new classes when you update your generate new classes when you update your specificationspecification

You need custom code attached to each class, and You need custom code attached to each class, and this will be overwritten when you re-run xsd.exe to this will be overwritten when you re-run xsd.exe to generate new classes (i.e., implicit conversion generate new classes (i.e., implicit conversion operators!)operators!)

Solution:Solution: Create classes that inherit your generated classesCreate classes that inherit your generated classes Write your custom code within the inheriting classWrite your custom code within the inheriting class

Page 13: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Creating Inherited Classes to work with GJXDM Data

public class DerivedContactInformationType : public class DerivedContactInformationType : Riss.DataExchange.GJXDM.ContactInformationTypeRiss.DataExchange.GJXDM.ContactInformationType

{{public void CustomMethod()public void CustomMethod(){{

……}}public static implicit operator…public static implicit operator…

}}

Page 14: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Dealing with XML Data: String or XML Document Object Model

(DOM)?

String:String: Faster than DOMFaster than DOM Not XML-awareNot XML-aware Good for sequentially building data stringGood for sequentially building data string Allows access to StringBuilder class, which is a substantially Allows access to StringBuilder class, which is a substantially

faster way to repeatedly append data to create a long stringfaster way to repeatedly append data to create a long string DOM:DOM:

Allows access to node data (through XPath) without parsingAllows access to node data (through XPath) without parsing Good for building data out of orderGood for building data out of order

Combination of the two is often effective: build parts as Combination of the two is often effective: build parts as strings, convert those to an XML type, then append them to strings, convert those to an XML type, then append them to your XML typeyour XML type

Tweaking these has resulted in substantial code efficiency Tweaking these has resulted in substantial code efficiency increases in RISSApps!increases in RISSApps!

Page 15: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Serialization and Deserialization

Serialization is the process of turning an object into Serialization is the process of turning an object into XML dataXML data

Deserialization is the process of turning XML data Deserialization is the process of turning XML data into an objectinto an object

Good way to quickly convert from XML to classes Good way to quickly convert from XML to classes and vice versaand vice versa

Applies to the public members and properties of the Applies to the public members and properties of the classclass

Page 16: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Serialization

A method to create XML string data out of the object data:A method to create XML string data out of the object data:

public string ToXml()public string ToXml(){{

trytry{{

XmlSerializer serializer = new XmlSerializer(typeof(MyClass));XmlSerializer serializer = new XmlSerializer(typeof(MyClass));MemoryStream stream = new MemoryStream();MemoryStream stream = new MemoryStream();serializer.Serialize(stream, this);serializer.Serialize(stream, this);System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();string Output = encoding.GetString(stream.ToArray());string Output = encoding.GetString(stream.ToArray());stream.Close();stream.Close();return Output;return Output;

}}catch (Exception err)catch (Exception err){{

throw new Exception("The XML string could not be created.\n" + throw new Exception("The XML string could not be created.\n" + err.Message);err.Message);}}

}}

Page 17: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Deserialization

A method to load XML data into the objectA method to load XML data into the object

public bool LoadFromXml(string preferenceXML)public bool LoadFromXml(string preferenceXML){{

trytry{{

XmlSerializer MySerializer = new XmlSerializer MySerializer = new XmlSerializer(typeof(MyClass));XmlSerializer(typeof(MyClass));

System.Text.ASCIIEncoding myEncoding = new ASCIIEncoding();System.Text.ASCIIEncoding myEncoding = new ASCIIEncoding();byte[] myByteArray = myEncoding.GetBytes(preferenceXML);byte[] myByteArray = myEncoding.GetBytes(preferenceXML);MemoryStream MyStream = new MemoryStream(myByteArray);MemoryStream MyStream = new MemoryStream(myByteArray);MyClass MyObject = MyClass MyObject =

(MyClass)MySerializer.Deserialize(MyStream);(MyClass)MySerializer.Deserialize(MyStream);return true;return true;

}}catch //(Exception err)catch //(Exception err){{

return false;return false;}}

}}

Page 18: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Serialization and Deserialization

Serialization uses the class, member, or property name as Serialization uses the class, member, or property name as the element name by defaultthe element name by default

Control of process possible through use of attributes placed Control of process possible through use of attributes placed before the class, such as [XmlArrayItem(“ElementArray”)]before the class, such as [XmlArrayItem(“ElementArray”)] XmlRoot renames and/or designates the top-level element of XmlRoot renames and/or designates the top-level element of

the XMLthe XML XmlIgnore causes the facet of the class to be skipped on XmlIgnore causes the facet of the class to be skipped on

serializationserialization XmlArray renames the XML element containing arrayXmlArray renames the XML element containing array XmlArrayItem renames the individual XML elements within the XmlArrayItem renames the individual XML elements within the

arrayarray XmlElement returns the array elements without a containerXmlElement returns the array elements without a container

Page 19: BAJ Bureau of Justice Assistance RISSTech RISSTech RISSApps Implementation of GJXDM through Microsoft Visual Studio

RISSBAJ Bureau of

Justice Assistance

RISSTechRISSTech

Thank You

Carl NelsonCarl NelsonLead DeveloperLead Developer

Regional Information Sharing SystemsRegional Information Sharing SystemsOffice of Information TechnologyOffice of Information Technology

Applications Development GroupApplications Development Group

545 Marriott Drive545 Marriott DriveSuite 800Suite 800

Nashville, Tennessee 37214Nashville, Tennessee 37214

Telephone: 615.871.0013Telephone: 615.871.0013

[email protected]@adg.riss.net