264515281 - Page 1 of 23
Document Control
Document Revision History
Version Name
Comments
Date
0.1
Datacom
Draft
06/11/2012
0.2
Datacom
07/11/2012
0.3
Datacom
Customs feedback
08/11/2012
0.4
JBMS
08/11/2012
Document Contributors
Name
Role
Andrew Savinykh
Chris Prior
Reviewers
Name
Organisation
Chris Prior
Customs
Related Documents
Document
Version
Organisation
Author
New Zealand
Custom Service
JBMS
0.1
New Zealand
Custom Service
JBMS
0.5
New Zealand
Custom Service
JBMS
0.1
New Zealand
Custom Service
JBMS
0.1
New Zealand
Custom Service
JBMS
1.0
New Zealand
Custom Service
JBMS
0.5
New Zealand
Custom Service
JBMS
0.5
New Zealand
Custom Service
JBMS
Prepared for
NZCS
264515281 - Page 2 of 23
Contents
TSW SOAP Interface...................................................................................1
1.
Document Purpose..............................................................................4
2.
Architecture/Modules Overview...........................................................5
3.
API Overview......................................................................................7
3.1 Submit Lodgement........................................................................................... 7
3.2 Request Lodge Response.................................................................................. 7
4.
API Considerations..............................................................................8
4.1 Certificates....................................................................................................... 8
4.2 Bindings............................................................................................................ 8
5.
Known Issues.....................................................................................9
5.1 Attachments are not being signed....................................................................9
5.2 There is no verification of the response signatures..........................................9
5.3 Push interface for responses is not utilized......................................................9
5.4 There is a potential for lost responses..............................................................9
5.5 Only one attachment per message is supported............................................10
5.6 A number of MIME message headers are static..............................................10
6.
264515281 - Page 3 of 23
1. Document Purpose
This document describes architecture and implementation of the Customs TSW B2B
gateway SOAP 1.1 client for .NET using a PUSH PULL interaction model for submitting
lodgements and receiving lodgement responses.
The Customs TSW B2B gateway exposes its endpoints with SOAP 1.1. SOAP and is a
well understood standard. However there are sometimes incompatibilities in
implementing an integration; often a fair amount of configuration effort is required as
well as specific code changes to support certain features of a protocol.
In particular, SOAP With Attachments protocol extension is not supported out of the
box by standard .Net libraries, preferring SOAP 1.2 and MTOM. With this in mind an
implementation of a .NET client, written in C#, to support SWA has been created.
The implementation is targeted to the developers that want to communicate with
Customs TSW B2B gateway from a .NET based application.
264515281 - Page 4 of 23
2. Architecture/Modules Overview
The following diagram represents the main components of the implemented solution
and related systems.
The .NET client is built on top of Windows Communication Foundation (WCF)
framework that is part of .NET Framework. The .NET Framework version 4.0 was used
whilst implementing the codebase using C#.
SWA Library:
Microsoft.Austria.WcfHelpers.SoapWithAttachments a custom message
encoder to support SOAP With Attachments specification. Originally published
by Microsoft Austria on codeplex at http://wcfswaencoder.codeplex.com/ and
modified to suite JBMS project needs
Jbms.Client:
o Client API this is the main endpoint a client application calls to
communicate with the Customs TSW B2B gateway
o Proxy these are classes that represent data structures required in the
Client API calls. Generated from the WSDL and then hand-modified to
work around interop issues.
264515281 - Page 5 of 23
264515281 - Page 6 of 23
Jbms.TestApp:
o Test application that demonstrate how to use Jbms.ServicesAPI
o Bindings configuration WCF bindings that are compatible with the
Customs TSW B2B gateway server configuration
Jbms.TestApp is not intended to be a part of any real-life solution, instead similar code
and bindings will become a part of each client application that wants to communicate
with the Customs TSW B2B gateway.
Note: These components are meant to be part of each individual client application
solution. There are no separate deployment requirements/scenarios for this apart from
those of encasing application. It is recommended, that these are added into the client
application Visual Studio solution in form of source code, so that any customisation
necessary is easier.
Components
Name
Version
Windows Server
2008 R2
Enterprise
.NET
4.0
Note: These are the version of components the solution was tested with. It is also likely
to work on other version of Windows as long as .NET version is 4.0. It might work on
.NET 3.5 but it is untested. It wont work on the earlier version of .NET.
264515281 - Page 7 of 23
3. API Overview
As of the moment of writing there are 2 APIs provided to communicate with the
Customs TSW B2B gateway.
264515281 - Page 8 of 23
Please see Appendix A for the list of the pseudo-code of the structures used for the
request and response. The endpointName optional parameter specifies the endpoint
name as specified in the bindings configuration.
264515281 - Page 9 of 23
Please see Appendix A for the list of the pseudo-code of the structures used for the
request and response. The endpointName optional parameter specifies the endpoint
name as specified in the bindings configuration.
264515281 - Page 10 of 23
4. API Considerations
264515281 - Page 11 of 23
4.1 Certificates
Access to the Customs TSW B2B gateway is secured by means of certificates. For each
particular client four certificates are used like so:
A server certificate for mutual SSL (the same for all clients)
A server certificate for message signature operations (the same for all clients)
These certificates have to be installed on the .NET Client machine in the following
manner:
264515281 - Page 12 of 23
4.2 Bindings
Most of the Bindings configuration, provided along with the JBMS.TestApp application,
does not need changing. However there are a few things that have to be customized:
Certificate names and locations as appropriate. The name should be the name
of the certificate you are using, and the location should be the location of the
store you installed it to:
<behaviorname="jbms_credentials_behavior">
<clientCredentials>
<!-- Change this line to specify your client certificate -->
<clientCertificatefindValue="extb2b.tsw.message.sig.clientName"storeLocation="LocalMachine"storeNam
e="My"x509FindType="FindBySubjectName" />
<serviceCertificate>
<!-- This certificate is to be obtained along with this code -->
<defaultCertificatefindValue="extb2b.tsw.message.sig.customs"storeLocation="LocalMachine"storeName
="My"x509FindType="FindBySubjectName" />
<authenticationcertificateValidationMode="None"trustedStoreLocation="LocalMachine"revocationMode="
NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
Service URL. Each endpoint (as of the moment of writing there are two) has its
own endpoint URL. This URL should be changed to point to the appropriate
server and the last part of the URL should correspond to the client certificate
used is the application:
<!-- Make sure to change everything after 'TP=' to keyword corresponded to your client
certificate -->
<endpointaddress="https://extb2b.tsw.govt.nz/soap?
service=TSW_WS_SUBMIT_LODGEMENT_SEC&TP=AS_AGREED_WITH_CUSTOMS"
264515281 - Page 13 of 23
5. Known Issues
264515281 - Page 14 of 23
264515281 - Page 15 of 23
264515281 - Page 16 of 23
264515281 - Page 17 of 23
264515281 - Page 18 of 23
264515281 - Page 19 of 23
264515281 - Page 20 of 23
264515281 - Page 21 of 23
264515281 - Page 22 of 23
264515281 - Page 23 of 23