04.10.2012 Views

Handbuch ESR

Handbuch ESR

Handbuch ESR

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

E-bill<br />

Instruction for a client implementation<br />

of the B2B web service<br />

Edition: August 2008


Contents<br />

1. Introduction....................................................................................................3<br />

2. Background ....................................................................................................3<br />

2.1 Preparation for implementation in C#............................................................................ 3<br />

2.2 Preparation for implementation in Java......................................................................... 3<br />

3. Specification ...................................................................................................4<br />

3.1 Web service for biller ....................................................................................................... 4<br />

3.1.1 Upload Services ......................................................................................................... 4<br />

3.1.1.1 The UploadFiles method.............................................................................................. 4<br />

3.1.1.2 The UploadFilesReport method.................................................................................... 5<br />

3.1.2 Download Services.................................................................................................... 5<br />

3.1.2.1 GetInvoiceListWithIDs.................................................................................................. 5<br />

3.1.2.2 GetInvoiceByID ............................................................................................................ 5<br />

3.1.2.3 GetInvoiceList (omitted)............................................................................................... 6<br />

3.1.2.4 GetInvoice (omitted).................................................................................................... 6<br />

3.1.2.5 GetProcessProtocolList................................................................................................. 6<br />

3.1.2.6 GetProcessProtocol...................................................................................................... 7<br />

3.1.2.7 GetRegistrationList ...................................................................................................... 7<br />

3.1.2.8 GetRegistration ........................................................................................................... 8<br />

3.2 Web service for payer ...................................................................................................... 8<br />

3.2.1 Download Services.................................................................................................... 8<br />

3.2.1.1 GetInvoiceListWithIDs.................................................................................................. 8<br />

3.2.1.2 GetInvoiceByID ............................................................................................................ 9<br />

3.2.1.3 The GetOpenList / GetArchiveList methods (omitted)................................................... 9<br />

3.2.1.4 The GetInvoices/GetInvoicesArchive methods ............................................................ 10<br />

3.2.1.5 The GetPDF / GetPDFArchive methods....................................................................... 10<br />

4. Implementation............................................................................................11<br />

4.1 Interfaces......................................................................................................................... 11<br />

4.2 Implementation in C#..................................................................................................... 12<br />

4.3 Implementation in Java ................................................................................................. 14<br />

5. Final comments ............................................................................................18<br />

Annex A..............................................................................................................19<br />

Links relating to the integration.............................................................................................. 19<br />

Links relating to production..................................................................................................... 19<br />

Files provided ............................................................................................................................ 19<br />

2/19


1. Introduction<br />

Within the e-bill project with PostFinance there is a requirement to allow bills to be uploaded and<br />

downloaded through an automated interface to/from the yellowbill system. The decision was to use SOAP<br />

web services for this purpose. For security reasons the web services must be implemented on the basis of<br />

WS-Security. This document serves as a brief instruction guide for a client implementation of the web<br />

services in the programming languages C# 1.1 (WSE2.0) and Java (JWSDP 1.5). Knowledge of the<br />

mentioned programming languages, the SOAP web services and the WS-Security specification is a<br />

requirement and those are therefore not further discussed in this document.<br />

2. Background<br />

You are a biller or a payer and wish to use the bill upload or download web services provided by<br />

PostFinance. You can implement your client in any programming language you wish as long as the XML<br />

requests correspond to the SOAP specifications with the WS-Security extension. Because those XMLs are<br />

fairly comprehensive there are a variety of frameworks that simplify implementation of the web services<br />

considerably. You therefore do not have to create the SOAP XML "by hand". This document describes the<br />

client implementation of the yellowbill web services in C# and Java.<br />

2.1 Preparation for implementation in C#<br />

In order to implement the client with Microsoft .NET, the .NET SDK 1.1 or .NET SDK 2.0 framework must<br />

be installed. It can be downloaded free of charge from ht tp://msdn2.microsoft.com/en-us/netframework/<br />

default.aspx. The WS-Security extensions which are part of Microsoft's WSE 2.0 for .NET 1.1 or WSE 3.0<br />

for .NET 2.0 (Web Services Enhancements) are also required. This package can also be downloaded free<br />

of charge at this link http://msdn2.microsoft.com/en-us/webservices/default.aspx. The presence of<br />

Microsoft’s Visual Studio 2003 or Visual Studio 2005 is an advantage but not a requirement. The SDK<br />

.NET framework provides all the necessary tools, e.g. compiler, generation of the proxy classes from the<br />

wsdl file, etc. Install the framework first and then WSE 2.0 respectively WSE 3.0.<br />

2.2 Preparation for implementation in Java<br />

If the client application has to be implemented in Java, you will require Java 2 Platform Standard Edition<br />

(J2SE), version 1.4.2 or higher. Sun provides it free of charge at ht tp://java.sun.com/j2se/index.jsp.<br />

An extension for the web service functionality is also required for Java. This package is called Java Web<br />

Services Developer Pack (Java WSDP) and can also be downloaded free of charge. Version 1.5 is required:<br />

ht tp://java.sun.com/webservices/jwsdp/index.jsp. Now you have all the necessary tools to create proxy<br />

classes, compiling, etc. Install J2SE first and then JWSDP.<br />

There are several other Java frameworks to implement web services (with the WS-Security extension), e.g.<br />

using Apache Axis or webMethods GLUE, etc. You are free to use any existing frameworks provided that<br />

they conform to the specifications.<br />

3/19


3. Specification<br />

The advantage of web services is that we will not have to worry about communications or the protocol<br />

on the client side or the server side. The various frameworks usually do this work for you. Thanks to the<br />

generated proxy classes the client can call up functionalities as if they were local classes. An explanation<br />

of the yellowbill web service functionalities follows.<br />

3.1 Web service for biller<br />

3.1.1 Upload Services<br />

The UploadInvoice web service is intended for billers and provides methods for uploading bill files.<br />

The following listed bill types are supported. The FileType determinate the file extension of the uploaded<br />

file. This is important for further processing.<br />

Bill Types FileType (File Extension)<br />

PDF bill detail for presentment "PDF"<br />

PDFOnly bill format "PDFOnly.PDF"<br />

ybInvoice or CreateBill format "XML"<br />

Custom XML bill format like SAPiDoc "EAI.XML"<br />

Custom EDIFACT bill format "EAI.EDI"<br />

3.1.1.1 The UploadFiles method<br />

The interface of the UploadFiles method is as follows:<br />

NotProcessedInvoice[] UploadFiles( Invoice[] invoices, String BillerID );<br />

The method expects an array of type Invoice (see below) and the BillerID of the biller to be passed. It<br />

returns an array of the type NotProcessedInvoice (see below).<br />

To avoiding timeout and peformance problems while uploading a greater amount of Invoices, we<br />

recommend to call the UploadFiles Methode for each Invoice rather than to upload them all together<br />

with one single call.<br />

The type Invoice is a self-declared data type representing a file. It is defined as follows:<br />

public class Invoice<br />

{<br />

public String FileType;<br />

public String TransactionID;<br />

public byte[] Data;<br />

}<br />

The FileType<br />

The TransactionID is the biller’s bill identification and must be identical to the one in the bill file. The<br />

Data field contains the file contents in the form of a binary stream. A byte array, however, cannot be<br />

simply transferred via http. The binary stream must be converted into a base64-encoded string and then<br />

converted back again on the other side. This conversion, however, is usually done automatically by the<br />

SOAP framework.<br />

The NotProcessedInvoice data type has the following structure:<br />

public class NotProcessedInvoice<br />

{<br />

public String FileType;<br />

public String TransactionID;<br />

}<br />

4/19


A NotProcessedInvoice entry indicates that the file could not be uploaded. The biller can tell which<br />

invoice is concerned by checking the TransactionID. The biller receives more detailed information in a<br />

separate processing log delivered daily.<br />

To comply with the WS-Security specification, requests always have a username token and a timeout.<br />

Further details below.<br />

3.1.1.2 The UploadFilesReport method<br />

The request for UploadFilesReport is similar to the method above. But in the response more detailed<br />

information about the transmission status of the files is given.<br />

The result is returned in the form of an array of type ProcessedInvoice with the following structure.<br />

public class ProcessedInvoice<br />

{<br />

public String FileType;<br />

public DateTime SubmitDate;<br />

public String TransactionID;<br />

public String ProcessingState;<br />

}<br />

This type of report entry corresponds to a daily report for each file type. The FileType may be one of the<br />

list above. The SubmitDate are date and time of the request and the TransactionID is the unique invoice<br />

ID supplied by the biller at upload. Processing contains the state of the submitted data. They may be<br />

"OK" or "NOK" by uploaded data. This information may be used for the download methods.<br />

3.1.2 Download Services<br />

The Download web service provides the biller with eight bill management methods. A distinction is made<br />

between outstanding bills, protocols and registrations (never downloaded) and archived data (already<br />

downloaded). It can be controlled by ArchiveData (true / false). Data already collected remain available<br />

for 40 days after the first download.<br />

3.1.2.1 GetInvoiceListWithIDs<br />

This method returns a report list of available bills with the most important details. It replaces the omitted<br />

method GetInvoiceList.<br />

The interfaces are as follows:<br />

InvoiceReportWithID[] GetInvoiceList( String BillerID, bool ArchiveData );<br />

The method expect the BillerID and the ArchiveData flag as parameters to be passed. To list already<br />

downloaded bills, the ArchiveData flag must be set to true.<br />

The result will be returned in an array of type InvoiceReportWithID with the following structure.<br />

public class InvoiceReportWithID<br />

{<br />

public String BillerID;<br />

public String TransactionID;<br />

public DateTime DeliveryDate;<br />

public String FileType;<br />

}<br />

This type of report contains the follwing details for each bill. The TransactionID is the unique invoice ID<br />

and the DeliveryDate is the invoice date supplied by the biller when uploading it. The FileType may be<br />

"RGXMLSIG"or "EDIFACT". Bills which are embedded as an appendix in a ybInvoice like the SAPiDoc are<br />

also of the FileType "RGXMLSIG". All this information may be used for the download methods.<br />

3.1.2.2 GetInvoiceByID<br />

This method allows to download a single signed invoice by its TransactionID. It replaces the omitted method<br />

GetInvoce. For obtaining the TransactionID, the GetInvoiceListWithID method has to be called first.<br />

DownloadFile GetInvoiceByID( String BillerID, string TransactionID );<br />

5/19


The BillerID and the TransactionID are expected as parameters to be passed. The downloaded file is<br />

returned in a structure of the type DownloadFile.<br />

public class DownloadFile<br />

{<br />

public byte[] Data;<br />

public String Filename;<br />

}<br />

It contains the Filename and the content in the form of a binary stream (Data). Now you can save it into<br />

a file. Any further processing of the invoice is in the responsibility of the biller.<br />

3.1.2.3 GetInvoiceList (omitted)<br />

This method is omitted. It’s recommended to use the GetInvoiceListWithIDs method instead.<br />

The method returns a list of available downloads with the most important details. The interfaces are as<br />

follows:<br />

Report[] GetInvoiceList( String BillerID, bool ArchiveData );<br />

The method expects the BillerID and the ArchiveData flag as parameters to be passed. For listing already<br />

downloaded bills, the ArchiveData flag must be set to true. The result will be returned as an array of<br />

type Report with the following structure.<br />

public class Report<br />

{<br />

public DateTime DeliveryDate;<br />

public String FileType;<br />

public int Count;<br />

}<br />

This type of report entry corresponds to a daily report for each file type. The DeliveryDate is the invoice<br />

date supplied by the biller when uploading it. The FileType may be "RGXMLSIG" or "EDIFACT". Count<br />

contains the number of downloadable files with the same DeliveryDate. This information may be used for<br />

the download methods.<br />

3.1.2.4 GetInvoice (omitted)<br />

This method is omitted. It’s recommended to use the GetInvoiceByID method instead.<br />

The method allows signed invoices to be downloaded of the given DeliveryDate.<br />

DownloadFile[] GetInvoices( String BillerID, DateTime DeliveryDate, boolean<br />

ArchiveData );<br />

The method expects the BillerID and the ArchiveData flag as parameters to be passed. For listing already<br />

downloaded bills, the ArchiveData flag must be set to true. Each downloaded file is returned in a<br />

structure of the type DownloadFile.<br />

public class DownloadFile<br />

{<br />

public byte[] Data;<br />

public String Filename;<br />

}<br />

It contains the Filename and the contents in the form of a binary stream (Data). You now save it into a<br />

file. Any further processing of the invoice is the biller’s responsibility.<br />

3.1.2.5 GetProcessProtocolList<br />

This method returns a list of available downloads with the most important details. The interfaces are as<br />

follows:<br />

Report[] GetProcessProtocolList( String BillerID, boolean ArchiveData );<br />

They expect the BillerID parameter (unique identifier of biller) to be passed. The result is returned in the<br />

form of an array of type ProtocolReport with the following structure.<br />

6/19


public class ProtocolReport<br />

{<br />

public DateTime CreateDate;<br />

public String FileType;<br />

}<br />

This type of report entry corresponds to a daily report for each file type. The CreateDate is the date of<br />

the creation by yellowbill system. The FileType is "P".<br />

3.1.2.6 GetProcessProtocol<br />

This method allow ProcessProtocols to be downloaded.<br />

DownloadFile[] GetProcessProtocol( String BillerID, DateTime CreateDate,<br />

boolean ArchiveData );<br />

Each downloaded file is returned in a structure of the type DownloadFile.<br />

public class DownloadFile<br />

{<br />

public byte[] Data;<br />

public String Filename;<br />

}<br />

It contains the Filename and the contents in the form of a binary stream (Data). You now save it into a<br />

file. Any further processing of the Process Protocol is the biller’s responsibility. Aditionnal explication for<br />

the Process Protocol is available in the e-bill manual.<br />

3.1.2.7 GetRegistrationList<br />

This method returns a list of available downloads with the most important details. The interfaces are as<br />

follows:<br />

Report[] GetRegistrationList( String BillerID, boolean ArchiveData );<br />

They expect the BillerID parameter to be passed. The result is returned in the form of an array of type<br />

ProtocolReport with the following structure.<br />

public class ProtocolReport<br />

{<br />

public DateTime CreateDate;<br />

public String FileType;<br />

}<br />

This type of report entry corresponds to a daily report for each file type. The CreateDate is the date of the<br />

creation by yellowbill system. The FileType is "R".<br />

7/19


3.1.2.8 GetRegistration<br />

This method allow registrations to be downloaded.<br />

DownloadFile[] GetRegistration( String BillerID, DateTime CreateDate,<br />

boolean ArchiveData );<br />

Each downloaded file is returned in a structure of the type DownloadFile.<br />

public class DownloadFile<br />

{<br />

public byte[] Data;<br />

public String Filename;<br />

}<br />

It contains the Filename and the contents in the form of a binary stream (Data). You now save it into a<br />

file. Any further processing of the registrations is the biller’s responsibility. Aditionnal explication for the<br />

registration information is available in the e-bill manual.<br />

3.2 Web service for payer<br />

3.2.1 Download Services<br />

The DownloadInvoice web service provides the payer with eight bill management methods. A distinction<br />

is made between outstanding bills (never downloaded and thus not yet paid) and archived bills (already<br />

downloaded). Bills already collected remain available in the archive for 40 days after the first download.<br />

The bills that can be collected are digitally signed XMLs.<br />

3.2.1.1 GetInvoiceListWithIDs<br />

This method returns a report list of available bills with the most important details. It replace the omitted<br />

methods GetOpenList and GetArchiveList.<br />

The interfaces are as follows:<br />

InvoiceReportWithID[] GetInvoiceListWithIDs( String eBillAccountID, bool<br />

ArchiveData );<br />

The method expects the eBillAccountID and the ArchiveData flag parameters to be passed. For listing<br />

already downloaded bills, the ArchiveData flag must be set to true. The result is returned as an array of<br />

type InvoiceReportWithID with the following structure.<br />

public class InvoiceReportWithID<br />

{<br />

public String BillerID;<br />

public String TransactionID;<br />

public DateTime DeliveryDate;<br />

public String FileType;<br />

}<br />

This type of report contains the follwing details for each bill. The BillerID is the Biller’s Identification. The<br />

TransactionID is the unique invoice ID and the DeliveryDate is the invoice date supplied by the biller<br />

when uploading it. The FileType may be "PDF", "RGXMLSIG"or "EDIFACT". Bills which are embedded<br />

as an appendix in a ybInvoice like the SAPiDoc are also of the FileType "RGXMLSIG". All this information<br />

may be used for the download methods.<br />

8/19


3.2.1.2 GetInvoiceByID<br />

This method allows to download a single signed invoice or a PDF billdetail by its TransactionID. It replaces<br />

the omitted method GetInvoces, GetInvoicesArchive, GetPDF and GetPDFArchive. For obtaining the<br />

BilerID and TransactionID, the GetInvoiceListWithID method has to be called first.<br />

DownloadFile GetInvoiceByID( string eBillAccountID, string BillerID, string<br />

TransactionID, string FileType );<br />

The eBillAccountID, BillerID, TransactionID and FileType are expected as parameters to be passed.<br />

The downloaded file is returned in a structure of the type DownloadFile.<br />

public class DownloadFile<br />

{<br />

public byte[] Data;<br />

public String Filename;<br />

}<br />

It contains the Filename and the content in the form of a binary stream (Data). Now you can save it into<br />

a file. Any further processing of the invoice is the responsibility of the payer.<br />

3.2.1.3 The GetOpenList / GetArchiveList methods (omitted)<br />

These methods are omitted. It’s recommended to use the GetInvoiceWithIDs method instead.<br />

Both methods return a list of available downloads with the most important details. The interfaces are as<br />

follows:<br />

Report[] GetOpenList( String eBillAccountID );<br />

Report[] GetArchiveList( String eBillAccountID );<br />

They expect the eBillAccountID parameter (unique identifier of payer) to be passed. The result is returned<br />

in the form of an array of type Report with the following structure.<br />

public class Report<br />

{<br />

public DateTime DeliveryDate;<br />

public String FileType;<br />

public int Count;<br />

}<br />

This type of report entry corresponds to a daily report for each file type. The DeliveryDate is the invoice<br />

date supplied by the biller when uploading it. The FileType may be "PDF", "RGXMLSIG" or "EDIFACT".<br />

Count contains the number of downloadable files with the same DeliveryDate. This information may be<br />

used for the download methods.<br />

9/19


3.2.1.4 The GetInvoices/GetInvoicesArchive methods<br />

These methods are omitted. It’s recommended to use the GetInvoiceByID method instead.<br />

These methods allow signed invoices to be downloaded. The yellowbill system considers any bill collected<br />

using GetInvoices as paid from this moment onwards. The payer is then responsible for settling the<br />

amount through the usual payment channels.<br />

DownloadFile[] GetInvoices( String eBillAccountID, DateTime DeliveryDate );<br />

DownloadFile[] GetInvoicesArchive( String eBillAccountID, DateTime DeliveryDate );<br />

Not only the eBillAccountID but also a DeliveryDate is supplied, as already mentioned above. It can be<br />

taken from the response above. Each downloaded file is returned in a structure of the type<br />

DownloadFile.<br />

public class DownloadFile<br />

{<br />

public byte[] Data;<br />

public String Filename;<br />

}<br />

It contains the Filename and the contents in the form of a binary stream (Data). You now save it into a<br />

file. Any further processing of the invoice is the payer’s responsibility.<br />

3.2.1.5 The GetPDF / GetPDFArchive methods<br />

These methods are omitted. It’s recommended to use the GetInvoiceByID method instead.<br />

These methods enable the invoice details to be downloaded as a PDF file (in print format). The bill<br />

recipient can then archive these details electronically. These methods are used in the same way as those<br />

above.<br />

DownloadFile[] GetPDF( String eBillAccountID, DateTime DeliveryDate );<br />

DownloadFile[] GetPDFArchive( String eBillAccountID, DateTime DeliveryDate<br />

);<br />

10/19


4. Implementation<br />

This section serves as a short tutorial on the implementation of the web service clients. The programming<br />

languages C# and Java will be addressed. For Java there are of course numerous frameworks for<br />

implementing SOAP web services. Only JWSDP will be addressed here.<br />

4.1 Interfaces<br />

The interface of a SOAP web service is described by the WSDL file (Web Service Description Language)<br />

which is published by the web service and describes the methods that can be called up by the client. This<br />

file serves as a basis so that the various frameworks can generate the necessary proxy classes.<br />

Please note that no information concerning the implemented WS-Security recommendations can be read<br />

from the WSDL file.<br />

The WSDL file for the upload web service is available at the following URL:<br />

ht tps://ebill-test.yellowworld.ch/B2BWebServices/UploadInvoice.asmx?WSDL<br />

The interface description for the download web service is at the following link:<br />

ht tps://ebill-test.yellowworld.ch/B2BWebServices/DownloadInvoice.asmx?WSDL<br />

11/19


4.2 Implementation in C#<br />

It is presumed that the preparations in section 2.1 have already been carried out. The first step is to<br />

generate the proxy classes. If you are working with Visual Studio .NET you can open a new or existing<br />

project. Then select "Add Web Reference" to add a web reference to the project. Enter the URL of the<br />

WSDL file in the window that now appears. Next, you can change the namespace, if necessary.<br />

The generated class is located in the Reference.cs file. In this case, minor adjustments have to be made to<br />

this file. We therefore recommend that you copy the contents of Reference.cs and paste them into a new<br />

file, e.g. UploadInvoiceProxy.cs. The new file can, for example, be stored in the project root folder.<br />

Because WSE 2.0 is being used, the class declaration needs to be changed:<br />

After generation it reads:<br />

public class UploadInvoice : System.Web.Services.Protocols.SoapHttpClientProtocol<br />

Edit it to read as follows:<br />

public class UploadInvoice : Microsoft.Web.Services2.WebServicesClientProtocol<br />

The reference to Microsoft.Web.Services2.dll also needs to be added to the project. The WebReferences<br />

directory can then be deleted provided that no other web services are linked in.<br />

The functionality of the new class can now be used just like an ordinary C# class.<br />

You can also create the proxy class with the wsdl command line tool. For our example the command<br />

syntax could be as follows:<br />

ws dl /n:B2BWebServices /o:UploadInvoiceProxy.cs /protocol:SOAP /l:CS<br />

ht tps://ebill-test.yellowworld.ch/B2BWebServices/UploadInvoice.asmx?WSDL<br />

In this case as well, the class has to be adjusted as above.<br />

Now for the implementation itself. Here we will only show the example of the biller, i.e. the upload client.<br />

The bill issuer must have a valid username and password. If possible these should be stored in a separate<br />

file or database and must on no account be accessible to unauthorized persons. First there is an initialization<br />

block in which the username, password and BillerID are read in. How you read them in is up to you.<br />

Invoice[] invoices = new Invoice[txtFilenames.Lines.Length];<br />

NotProcessedInvoice[] npInvoices = null;<br />

String Username = ……;<br />

String Password = ……;<br />

String BillerID = ……;<br />

Next, the invoices array is filled with the FileType, TransactionID and Data of each file. This should present<br />

no problems.<br />

The WS-Security specification defines a username token which can be used for authenticating web<br />

services (for further information refer to<br />

ht tp://w ww.oasis-open.org/committees/download.php/16782/wss-v1.1-spec-os<br />

UsernameTokenProfile.pdf).<br />

12/19


Because the web service is located behind a proxy, a redirection URL and a destination URL have to be<br />

specified when initializing the proxy class.<br />

UploadServiceDestination ht tps://ebill-test.yellowworld.ch:9443/B2BWebServices/UploadInvoice.asmx<br />

UploadServiceVia ht tps://ebill-test.yellowworld.ch/B2BWebServices/UploadInvoice.asmx<br />

UsernameToken token = new UsernameToken( Username, Password, PasswordOption.SendPlainText );<br />

UploadInvoiceProxy.UploadInvoiceProxy uploadProxy = new<br />

UploadInvoiceProxy.UploadInvoiceProxy();<br />

Microsoft.Web.Services2.Addressing.EndpointReference epr = new<br />

Microsoft.Web.Services2.Addressing.EndpointReference(new<br />

Uri(ConfigurationSettings.AppSettings["UploadServiceDestination"]));<br />

epr.Via = new Uri(ConfigurationSettings.AppSettings["UploadServiceVia"]);<br />

uploadProxy.Destination = epr;<br />

uploadProxy.RequestSoapContext.Security.Tokens.Add( token );<br />

For stronger authentication security it’s fairly recommended to use additionally to the username token,<br />

the binary security token (for further information refer to<br />

ht tp://ww w.oasis-open.org/committees/download.php/16785/wss-v1.1-spec-os-x509TokenProfile.pdf).<br />

To use a binary security token, a client certificate is required. The following example shows how to<br />

implement a binary security token in a webservice client.<br />

// create SecurityToken<br />

X509SecurityToken x509Token = new X509SecurityToken(x509Certificate);<br />

// add SecurityToken<br />

uploadProxy.RequestSoapContext.Security.Tokens.Add(x509Token);<br />

// sign the message<br />

uploadProxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(x509Token));<br />

For a further level of security, WS-Security defines a timestamp<br />

ht tp://w ww.oasis-open.org/committees/download.php/16790/wss-v1.1-spec-os-SOAPMessageSecurity.pdf<br />

with which you can ensure that the request is only valid for a certain time period.<br />

uploadProxy.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;<br />

Now comes the actual web service call.<br />

npInvoices = uploadProxy.UploadFiles(invoices, BillerID);<br />

The client must have the time zone set to GMT +1 and the time difference between client and server may<br />

not exceed more than 1 minute.<br />

Finally, a simple evaluation of the returned value is performed.<br />

StringBuilder sb = new StringBuilder();<br />

if (npInvoices != null && npInvoices.Length > 0)<br />

{<br />

sb.Append("Nicht eingelieferte Files!\r\n");<br />

sb.Append("**************************\r\n\r\n");<br />

for (int i=0; i


4.3 Implementation in Java<br />

As already mentioned, we will discuss only the JWSDP 1.5 framework. The preparations described in<br />

section 2.2 must have been completed. Here, too, the first step is to generate the proxy classes. The Sun<br />

documentation is usually based on the assumption that one wants to publish a web service and therefore<br />

they require the installation of a web container such as Tomcat. In our case, we really only need the client<br />

and there is thus no need for an application server or web container.<br />

The generation of client proxy classes using WS-Security extensions is not well documented. Therefore, we<br />

recommend that you take the enclosed configuration files and edit them.<br />

First of all, the webserviceclient.props file has to be edited. Values must be assigned to all parameters<br />

except the proxy information. The meanings of the individual parameters can be taken from the<br />

comments in Fig 1.<br />

# place where Java is installed<br />

javahome=C:/Java/2sdk1.4.2_07<br />

# place where JWSDP is installed<br />

jwsdp.home=C:/Java/jwsdp-1.5<br />

# Destination of the generated classes<br />

build.dir=build<br />

# Destination of generated jar File<br />

dist.dir=dist<br />

# Location of the Configuration-File<br />

configfile=config/client-config.xml<br />

# Proxy Server Host if there is one<br />

proxy.host=<br />

# Proxy Server Port if there is a Proxy Server<br />

proxy.port=<br />

# Name of the jar File<br />

jarname=DownloadInvoiceProxy<br />

# Set to true or false to control jaxrpc tool output<br />

jaxrpc.tool.verbose=true<br />

Fig 1: Contents of the webserviceclient.props file<br />

The webserviceclient.xml file is a control file for the ant tool which is included in the JWSDP package. It is<br />

located in \apache-ant\bin. The XML file references the configuration above, assembles<br />

the class path, contains compiler instructions for generating classes and much more. In our case, nothing<br />

has to be changed in this file. We still recommend, however, that you have a look at it in order to<br />

understand the procedure.<br />

Next, the client-config.xml file has to be edited. Here you have to enter the URL of the WSDL file and the<br />

name of the package to be generated.<br />

<br />

<br />

<br />

<br />

Fig 2: Contents of the client-config.xml file<br />

14/19


There is another configuration file called user-pass-authenticate-client.xml. This file contains all the<br />

information necessary to ensure that the WS-Security extensions are included when generating the proxy<br />

classes.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Yellowworld.WSSecurirty.ClientSecurityEnvironmentHandler<br />

<br />

Fig 3: Contents of user-pass-authenticate-client.xml<br />

This configuration file defines that the SOAP request must contain a username token and a<br />

timestamp (as per WS-Security specification<br />

ht tp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0.pdf and<br />

ht tp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0.pdf).<br />

The framework automatically inserts this XML node at runtime. You do not have to do this.<br />

The only thing you may have to change here is the class name of the callback handler. In our case this is<br />

the ClientSecurityEnvironmentHandler. In this class you can define how you wish to read in the username<br />

and password, e.g. from a file, from a database, etc.<br />

Once you have made all the necessary changes, you can start generating the proxy classes with the ant<br />

tool. To do this, enter the following command on the command line:<br />

ant –f webserviceclient.xml<br />

15/19


The procedure is logged in the cmd window and takes a few seconds. The generated source files, the<br />

compiled classes and the complete jar are now available in the Build directory. The jar file must be now be<br />

referenced when implementing the client program on the classpath. A whole lot of jar files have to be<br />

included in the class path in order to be able to compile and execute the client program. These are listed<br />

below.<br />

<br />

• jwsdp-shared<br />

jaxp<br />

jaxrpc<br />

saaj<br />

xws-security<br />

lib<br />

lib<br />

lib<br />

lib<br />

lib<br />

activation.jar<br />

jax-qname.jar<br />

mail.jar<br />

endorsed<br />

jaxp-api.jar<br />

jaxrpc-impl.jar<br />

jaxrpc-spi.jar<br />

jaxrpc-api.jar<br />

saaj-impl.jar<br />

saaj-api.jar<br />

security-plugin.jar<br />

soapprocessor.jar<br />

xmlsec.jar<br />

xws-security_jaxrpc.jar<br />

xws-security.jar<br />

dom.jar<br />

xercesImpl.jar<br />

xalan.jar<br />

Now for the implementation of the client. Our example here will show the retrieval of the list of open<br />

bills, i.e. the biller’s view. This person must have a valid username and password. If possible, these should<br />

be stored in a separate file or database and must on no account be accessible to unauthorized persons.<br />

First, there is an initialization block. In this example, the URLs of the web service and the eBillAccountID<br />

are stored in a properties file and read in via a property object. However, you can decide about this<br />

yourself. The important thing is to initialize the stub class and set the ENDPOINT_ADDRESS_PROPERTY.<br />

String serviceURL = pApplication.getProperty("ServiceUrl");<br />

DownloadInvoiceSoap_Stub stub =<br />

(DownloadInvoiceSoap_Stub)(dwnlService.getDownloadInvoiceSoap());<br />

stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, serviceURL);<br />

String eBillAccountID = pApplication.getProperty("eBillAccountID");<br />

Next, you can already call up the method itself, because the proxy classes add the WS-Security extensions<br />

here (see Fig 3).<br />

ArrayOfReport report = stub.getOpenList(eBillAccountID);<br />

16/19


Next, there is a simple evaluation of the returned value. We recommend that you save these returned<br />

values so that the actual XML or PDF files can be retrieved.<br />

Report[] arrReport = report.getReport();<br />

System.out.println("*** Open List ***");<br />

System.out.println();<br />

if (arrReport.length > 0)<br />

{<br />

for (int i=0; i


5. Final comments<br />

This document has shown a simple reference implementation for the use of the web services in the<br />

environment of the yellowbill system. For the sake of brevity, the details of SOAP, WS-Security, .NET, C#,<br />

Java, etc were deliberately omitted.<br />

The web service links provided in the document refer to our integration platform on which new customer<br />

connections are usually tested when they are set up. Due to possible maintenance windows, we cannot<br />

guarantee 100% availability of the integration platform.<br />

The links and a list of the enclosed documents are listed once more in the Annex.<br />

18/19


Annex A<br />

Links relating to the integration<br />

• Biller upload web service<br />

WSDL ht tps://ebill-test.yellowworld.ch/B2BWebservices/UploadInvoice.asmx?WSDL<br />

Webservices ht tps://ebill-test.yellowworld.ch/B2BWebservices/UploadInvoice.asmx<br />

• Biller download web service<br />

WSDL ht tps://ebill-test.yellowworld.ch/B2BWebServices/BillerDownloadServices.asmx?WSDL<br />

Webservices ht tps://ebill-test.yellowworld.ch/B2BWebServices/BillerDownloadServices.asmx<br />

• Payer download web service<br />

WSDL ht tps://ebill-test.yellowworld.ch/B2BWebservices/DownloadInvoice.asmx?WSDL<br />

Webservices ht tps://ebill-test.yellowworld.ch/B2BWebServices/DownloadInvoice.asmx<br />

Links relating to production<br />

• Biller upload web service<br />

WSDL ht tps://ebill.yellowworld.ch/B2BWebservices/UploadInvoice.asmx?WSDL<br />

Webservices ht tps://ebill.yellowworld.ch/B2BWebservices/UploadInvoice.asmx<br />

• Biller download web service<br />

WSDL ht tps://ebill.yellowworld.ch/B2BWebServices/BillerDownloadServices.asmx?WSDL<br />

Webservices ht tps://ebill.yellowworld.ch/B2BWebServices/BillerDownloadServices.asmx<br />

• Payer download web service<br />

WSDL ht tps://ebill.yellowworld.ch/B2BWebservices/DownloadInvoice.asmx?WSDL<br />

Webservices ht tps://ebill.yellowworld.ch/B2BWebservices/DownloadInvoice.asmx<br />

Files provided<br />

The preparations described in section 2.1 and section 2.2 are necessary for the generation of proxy classes<br />

to work.<br />

C#<br />

…\C#\bin<br />

Complete testing program as a Windows GUI. The .NET framework must be installed on<br />

the local machine.<br />

…\C#\ProxyGeneration<br />

Batch files for generating the proxy classes. The wsdl files are also included for your<br />

information. It is, however, better to reference the files online on the web server.<br />

…\C#\src Here is the source code including the Visual Studio .NET project file for the test client.<br />

Java<br />

…\Java\bin<br />

Test program for download as a console application. Java Runtime JRE 1.4.1 or higher<br />

must be installed.<br />

…\Java\ProxyGeneration\<br />

DownloadClientGenerator<br />

Batch file and configuration files for generating the proxy classes for the download client.<br />

…\Java\ProxyGeneration\<br />

UploadClientGenerator<br />

Batch file and configuration files for generating the proxy classes for the upload client.<br />

…\Java\src Java source code for the download test client.<br />

19/19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!