Skip to content

Commit

Permalink
Extend sample with more services calls (#2)
Browse files Browse the repository at this point in the history
* Added sample client for OIOLedsageDokumentSamlingHent and updated server certificate (test env.).
* Added sample client for OIOBeskedAfvisningSamlingHent
  • Loading branch information
cdcurry authored Nov 20, 2017
1 parent 37b47f3 commit 0a761f3
Show file tree
Hide file tree
Showing 60 changed files with 1,612 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ buildNumber.properties
.idea
*.iml
# Do not add:
run.sh
run-submit.sh
run-fetch.sh
run-fetch-ie704.sh
126 changes: 114 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.com/skat/emcs-b2b-ws-sample-client-java.svg?token=pXpLRS1qCgHe3KVdbFyA&branch=master)](https://travis-ci.com/skat/emcs-b2b-ws-sample-client-java)

Sample client for the EMCS B2B Web Service Gateway developed in Java and using open source libraries.
Sample clients for the EMCS B2B Web Service Gateway developed in Java and using open source libraries.

**IMPORTANT NOTICE**: SKAT does not provide any kind of support for the code in this repository.
This Java-client is just one example of how a B2B web service can be accessed. The client must not be
Expand All @@ -20,16 +20,23 @@ anvender klienten eller dele af denne i deres egne systemer.

## About the client

The sample client in is implemented based on the [Apache CXF](http://cxf.apache.org/) framework,
The sample clients are implemented based on the [Apache CXF](http://cxf.apache.org/) framework,
the Spring Framework, and Java 8. See `pom.xml` file in this repo for details regarding
the current versions of the mentioned frameworks in use.

The client currently implements calls to the service **OIOLedsageDocumentOpret** and the main entry
point into the source code of implementation is the class:
The sample clients currently implements calls to the services:

* **OIOLedsageDocumentOpret**
* **OIOLedsageDokumentSamlingHent**
* **OIOBeskedAfvisningSamlingHent**

The main entry point into the source code of the implementation is these classes:

[OIOLedsageDocumentOpretClient.java](src/main/java/dk/skat/emcs/b2b/sample/OIOLedsageDocumentOpretClient.java)
* [OIOLedsageDocumentOpretClient.java](src/main/java/dk/skat/emcs/b2b/sample/OIOLedsageDocumentOpretClient.java)
* [OIOLedsageDokumentSamlingHentClient.java](src/main/java/dk/skat/emcs/b2b/sample/OIOLedsageDokumentSamlingHentClient.java)
* [OIOBeskedAfvisningSamlingHentClient.java](src/main/java/dk/skat/emcs/b2b/sample/OIOBeskedAfvisningSamlingHentClient.java)

This class constructs the request, invokes a Apache CXF generated client, and parses the response
These classes construct the request, invokes a Apache CXF generated client, and parses the response
by printing out relevant values to the log.

## Fulfillment of WS Policy of EMCS Web Services
Expand All @@ -43,20 +50,33 @@ the `emcs-policy.xml` file details which parts are to be signed and encrypted, a
certificate for authentication on the server side. This configuration file also demonstrates how
secure transport (https) is enabled client side.

## Run client
## Run clients

The sample client must be configured with two required parameters that are necessary for the client to run and
The sample clients must be configured with JVM parameters that are necessary for the client to run and
call the test environment of EMCS B2B Web Service Gateway. The two parameters can be obtained by contacting
SKAT Help Desk.

The full list of parameters:
The full list of parameters for running a test against the **OIOLedsageDocumentOpret** service:

* **dk.skat.emcs.b2b.sample.P12_PASSPHRASE** (REQUIRED): Passphrase to the certificate used for authentication, signing (request), and encryption (response).
* **dk.skat.emcs.b2b.sample.OIOLedsageDocumentOpret.ENDPOINT** (REQUIRED):The endpoint of the OIOLedsageDocumentOpret service being invoked.
* **dk.skat.emcs.b2b.sample.TXID_PREFIX** (OPTIONAL): This parameter sets a custom prefix to the generated transaction id and is very useful when asking SKAT Help Desk to trace a particular request.

The full list of parameters for running a test against the **OIOLedsageDokumentSamlingHent** service:

* **dk.skat.emcs.b2b.sample.P12_PASSPHRASE** (REQUIRED): Passphrase to the certificate used for authentication, signing (request), and encryption (response).
* **dk.skat.emcs.b2b.sample.OIOLedsageDocumentOpret.ENDPOINT** (REQUIRED):The endpoint of the service being invoked.
* **dk.skat.emcs.b2b.sample.OIOLedsageDokumentSamlingHent.ENDPOINT** (REQUIRED):The endpoint of the OIOLedsageDokumentSamlingHent service being invoked.
* **dk.skat.emcs.b2b.sample.ARCX** (REQUIRED): ARC Number
* **dk.skat.emcs.b2b.sample.TXID_PREFIX** (OPTIONAL): This parameter sets a custom prefix to the generated transaction id and is very useful when asking SKAT Help Desk to trace a particular request.

The client is then invoked as part of the **test phase** of the Maven build process that is run using the following
command line:
The full list of parameters for running a test against the **OIOBeskedAfvisningSamlingHent** service:

* **dk.skat.emcs.b2b.sample.P12_PASSPHRASE** (REQUIRED): Passphrase to the certificate used for authentication, signing (request), and encryption (response).
* **dk.skat.emcs.b2b.sample.OIOBeskedAfvisningSamlingHent.ENDPOINT** (REQUIRED):The endpoint of the OIOBeskedAfvisningSamlingHent service being invoked.
* **dk.skat.emcs.b2b.sample.TXID_PREFIX** (OPTIONAL): This parameter sets a custom prefix to the generated transaction id and is very useful when asking SKAT Help Desk to trace a particular request.

The client is then invoked as part of the **test phase** of the Maven build process using the following
command:

```sh
$ mvn clean install \
Expand Down Expand Up @@ -109,6 +129,7 @@ First ensure that the the following fields in the `ie815.xml` file are unique:
Then run the client again and the EMCS System will produce an ARC Identifier.

**Sample response**:

```
*******************************************************************
** HovedOplysningerSvar
Expand All @@ -120,6 +141,87 @@ Ledsagedokument ARC Identifikator: 17DKK1KHPMQH2W23ABI62
*******************************************************************
```

## Fetch IE801 documents using OIOLedsageDokumentSamlingHent

The service **OIOLedsageDokumentSamlingHent** returns IE801 documents and in the following
sample we call this service using as search input the ARC number received in the sample response
above (`Ledsagedokument ARC Identifikator: 17DKK1KHPMQH2W23ABI62`).

The client for **OIOLedsageDokumentSamlingHent** is invoked as part of the **test phase** of the Maven
build process using the following command:


```sh
$ mvn clean install \
-Ddk.skat.emcs.b2b.sample.P12_PASSPHRASE=<CHANGE_THIS> \
-Ddk.skat.emcs.b2b.sample.OIOLedsageDokumentSamlingHent.ENDPOINT=<CHANGE_THIS>
-Ddk.skat.emcs.b2b.sample.ARC=17DKK1KHPMQH2W23ABI62 \
-Ddk.skat.emcs.b2b.sample.TXID_PREFIX=ACME_01_
```

This service returns a **response** similar to this output:

```
*******************************************************************
** HovedOplysningerSvar
**** Transaction Id: ACME_01_7586f935-6997-47d1-83a0-f70ec7a64d8f
**** Transaction Time: 2017-11-20T12:24:39.425+01:00
**** Service Identification: FS2_OIOLedsageDokumentSamlingHent
*******************************************************************
** IE 801 Messages:
<IE801 xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:client="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:IE801:V1.76"
xmlns="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:IE801:V1.76">
<ns25:Header xmlns:ns25="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:IE801:V1.76">
<ns19:MessageSender xmlns:ns19="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V1.76">NDEA.DK</ns19:MessageSender>
<ns19:MessageRecipient xmlns:ns19="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V1.76">NDEA.DK
</ns19:MessageRecipient>
<ns19:DateOfPreparation xmlns:ns19="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V1.76">2011-10-26
</ns19:DateOfPreparation>
<ns19:TimeOfPreparation xmlns:ns19="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V1.76">11:23:00.803
</ns19:TimeOfPreparation>
<ns19:MessageIdentifier xmlns:ns19="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V1.76">DKEMCS20170000000287316
</ns19:MessageIdentifier>
</ns25:Header>
<ns25:Body xmlns:ns25="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:IE801:V1.76">
...
...
...
...
</ns25:Body>
</IE801>
*******************************************************************
```

*NOTE*: The XML above is pretty printed and the body part removed (to avoid filling up the whole README file).

## Fetch IE704 documents using OIOBeskedAfvisningSamlingHent

The client for **OIOBeskedAfvisningSamlingHent** is invoked as part of the **test phase** of the Maven
build process using the following command:

```sh
$ mvn clean install \
-Ddk.skat.emcs.b2b.sample.P12_PASSPHRASE=<CHANGE_THIS> \
-Ddk.skat.emcs.b2b.sample.OIOBeskedAfvisningSamlingHent.ENDPOINT=<CHANGE_THIS>
-Ddk.skat.emcs.b2b.sample.TXID_PREFIX=ACME_01_
```

The client is configured to search for documents within the last month. If there are no 704 messages found,
the service returns a **response** similar to this output:

```
*******************************************************************
** HovedOplysningerSvar
**** Transaction Id: ACME_01_9c0848aa-366f-4765-9e1b-ddfbdb86aed1
**** Transaction Time: 2017-11-20T13:23:12.630+01:00
**** Service Identification: FS2_OIOBeskedAfvisningSamlingHent
*******************************************************************
**** Advis
****** Advis Code: 130
****** Advis Text: Der blev ikke fundet nogen beskeder som matcher de indikeret søgeparametre
```

## Advanced Configuration

### Testing Expired and Revoked Certificates
Expand Down
34 changes: 33 additions & 1 deletion pem/emcs-test-system.pem
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
-----BEGIN CERTIFICATE-----
MIIGIDCCBQigAwIBAgIEUw9paTANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQGEwJESzESMBAGA1UECgwJVFJVU1QyNDA4MSQwIgYDVQQDDBtUUlVTVDI0MDggU3lzdGVtdGVzdCBYSVggQ0EwHhcNMTQxMTAzMTAzMTAyWhcNMTcxMTAzMTAzMDAzWjCBjjELMAkGA1UEBhMCREsxKjAoBgNVBAoMIVNrYXR0ZW1pbmlzdGVyaWV0IC8vIENWUjoxOTU1MjEwMTFTMCAGA1UEBRMZQ1ZSOjE5NTUyMTAxLVVJRDoyMTcyMTczMjAvBgNVBAMMKFNrYXR0ZW1pbmlzdGVyaWV0IC0gQjJCIGdhdGV3YXkgVFNFIFRFU1QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCO6MDX8l0SFNxZ3LZFX8+p88fWtdEL+r3nLQDESlOKlgBH+u7Rdzd/C8H0P0dQ8Zyq2mgFkWQ4vLR9nutaYsouPD8CVUn0hx7ZdKEpqIgeaI0Y2626rLiqJUinMdmch0Jmcjw70tK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BAMMBkNSTDEyNjAfBgNVHSMEGDAWgBTMAlUM5IF0ryBU1REU
V5yRUjh/oDAdBgNVHQ4EFgQUHxNUb8fnAT3AoMfDDCrw4KH0d4kwCQYDVR0TBAIw
ADANBgkqhkiG9w0BAQsFAAOCAQEAapXLKQXxzya6N8OgrkSWkUTxO44M+wrqjRys
65D9AKX9+aYwk1b9wJLQxs0Rctloo+NbxQil5sMT+lRi6N05e+MuLMl/3wv7Fefh
7PwVF4FDCYSPvjQBOf5uPQYsGjz99XlbrOt+n0ufxtA+J/D3Re1e3yi8UjJ0921o
hXfMNdJw0B/xXTRMztV+FK0BGvFt3U5OCYUDjpzTCGYBmzxndtyo9xVfZF+/6MLC
2gSZmsWJpWq0bR5PFkLJ59UvUVUfyul94w01M/ra9Fv8DtwzOsRm0C//L14nvG9a
L9JmeE+0R7hJyBFen1X39HS3STOHYD/uWhkimCzZToYla4bgBQ==
-----END CERTIFICATE-----
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>dk.skat.emcs.b2b.sample</groupId>
<artifactId>emcs-b2b-ws-sample-client-java</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<version>1.1</version>
<name>emcs-b2b-ws-sample-client-java</name>
<url>http://www.skat.dk/emcs</url>
<properties>
Expand Down Expand Up @@ -81,6 +81,12 @@
<wsdlOption>
<wsdl>${basedir}/src/main/resources/OIOLedsageDokumentOpret/OIOLedsageDokumentOpret.wsdl</wsdl>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/OIOLedsageDokumentSamlingHent/OIOLedsageDokumentSamlingHent.wsdl</wsdl>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/OIOBeskedAfvisningSamlingHent/OIOBeskedAfvisningSamlingHent.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
Expand Down
Loading

0 comments on commit 0a761f3

Please sign in to comment.