You
can create a .NET client assembly to invoke a LiveCycle
service from a Microsoft Visual Studio .NET project. To create a
.NET client assembly that uses base64 encoding, perform the following
steps:
Create a proxy class based on a LiveCycle invocation
URL.
Create a Microsoft Visual Studio .NET project that produces
the .NET client assembly.
Creating a proxy class
You can create
a proxy class that is used to create the .NET client assembly by using
a tool that accompanies Microsoft Visual Studio. The name of the
tool is wsdl.exe and it is located in the Microsoft Visual Studio
installation folder. To create a proxy class, open the command prompt
and navigate to the folder that contains the wsdl.exe file. For
more information about the wsdl.exe tool, see the MSDN Help.
Enter
the following command at the command prompt:
wsdl http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?WSDL&lc_version=9.0.1
By
default, this tool creates a CS file in the same folder that is
based on the name of the WSDL. In this situation, it creates a CS
file named EncryptDocumentService.cs. You use this CS file
to create a proxy object that lets you invoke the service that was
specified in the invocation URL.
Amend the URL in the proxy
class to include ?blob=base64 to ensure that the BLOB object
returns binary data. In the proxy class, locate the following line
of code:
"http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument";
and
change it to:
"http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?blob=base64";
The Invoking LiveCycle using Base64 Encoding section
uses MyApplication/EncryptDocument as an example.
If you are creating a .NET client assembly for another LiveCycle service, ensure that you replace MyApplication/EncryptDocument with
the name of the service.
Developing the .NET client assembly
Create
a Visual Studio Class Library project that produces a .NET client
assembly. The CS file that you created using wsdl.exe can be imported
into this project. This project produces a DLL file (the .NET client
assembly) that you can use in other Visual Studio .NET projects
to invoke a service.
Start Microsoft Visual Studio .NET.
Create a Class Library project and name it DocumentService.
Import the CS file that you created using wsdl.exe.
In the Project menu, select Add Reference.
In the Add Reference dialog box, select System.Web.Services.dll.
Click Select and then click OK.
Compile and build the project.
Remarque : This
procedure creates a .NET client assembly named DocumentService.dll that
you can use to send SOAP requests to the MyApplication/EncryptDocument service.
Important : Make sure that you added ?blob=base64 to
the URL in the proxy class that is used to create the .NET client
assembly. Otherwise, you cannot retrieve binary data from the BLOB object.
Referencing the .NET client assembly
Place
your newly created .NET client assembly on the computer where you
are developing your client application. After you place the .NET
client assembly in a directory, you can reference it from a project.
Also reference the System.Web.Services library
from your project. If you do not reference this library, you cannot
use the .NET client assembly to invoke a service.
In the Project menu, select Add Reference.
Click the .NET tab.
Click Browse and locate the DocumentService.dll file.
Click Select and then click OK.
Invoking a service using a .NET client assembly that uses Base64 encoding
You can invoke the MyApplication/EncryptDocument service
(which was built in Workbench) using a .NET client assembly that
uses Base64 encoding. To invoke the MyApplication/EncryptDocument service,
perform the following steps:
Create a Microsoft .NET
client assembly that consumes the MyApplication/EncryptDocument service
WSDL.
Create a client Microsoft .NET project. Reference the Microsoft
.NET client assembly in the client project. Also reference System.Web.Services.
Using the Microsoft .NET client assembly, create a MyApplication_EncryptDocumentService object
by invoking its default constructor.
Set the MyApplication_EncryptDocumentService object’s Credentials property
with a System.Net.NetworkCredential object. Within
the System.Net.NetworkCredential constructor, specify
a LiveCycle user name and the corresponding password. Set authentication
values to enable your .NET client application to successfully exchange
SOAP messages with LiveCycle.
Create a BLOB object by using its constructor.
The BLOB object is used to store a PDF document
pass to the MyApplication/EncryptDocument process.
Create a System.IO.FileStream object by
invoking its constructor. Pass a string value that represents the
file location of the PDF document and the mode in which to open
the file.
Create a byte array that stores the content of the System.IO.FileStream object.
You can determine the size of the byte array by getting the System.IO.FileStream object’s Length property.
Populate the byte array with stream data by invoking the System.IO.FileStream object’s Read method.
Pass the byte array, the starting position, and the stream length
to read.
Populate the BLOB object by assigning its binaryData property
with the contents of the byte array.
Invoke the MyApplication/EncryptDocument process
by invoking the MyApplication_EncryptDocumentService object’s invoke method
and passing the BLOB object that contains the PDF
document. This process returns an encrypted PDF document within
a BLOB object.
Create a System.IO.FileStream object by
invoking its constructor and passing a string value that represents
the file location of the password-encrypted document.
Create a byte array that stores the data content of the BLOB object
returned by the MyApplicationEncryptDocumentService object’s invoke method.
Populate the byte array by getting the value of the BLOB object’s binaryData data
member.
Create a System.IO.BinaryWriter object by
invoking its constructor and passing the System.IO.FileStream object.
Write the byte array contents to a PDF file by invoking the System.IO.BinaryWriter object’s Write method
and passing the byte array.
Quick Start: Invoking a service using base64 in a Microsoft .NET project