Within the ASP.NET project, add a web form (an ASPX file)
that is responsible for displaying an HTML page to the loan applicant.
The web form is based on a class that is derived from System.Web.UI.Page.
The C# application logic that invokes FirstAppSolution/PreLoanProcess is
located in the Button1_Click method (this button
represents the Submit Application button).
The following illustration shows the ASP.NET application
The following table lists the controls that are part of this
ASP.NET application.
Control name
|
Description
|
TextBoxName
|
Specifies the customer’s first and last
name.
|
TextBoxPhone
|
Specifies the customer’s phone or email
address.
|
TextBoxAmount
|
Specifies the loan amount.
|
Button1
|
Represents the Submit Application button.
|
LabelJobID
|
A Label control that specifies the value
of the invocation identifier value.
|
LabelStatus
|
A Label control that specifies the value
of the job status. This value is retrieved by invoking the Job Manager
service.
|
The application logic that is part of the ASP.NET application
must dynamically create an XML data source to pass to the FirstAppSolution/PreLoanProcess process.
The values that the applicant entered into the HTML page must be
specified within the XML data source. These data values are merged
into the form when the form is viewed in Workspace. The classes
located in the System.Xml namespace are used to create
the XML data source.
When invoking a process that requires XML data from an ASP.NET
application, an XML data type is available for you to use. That
is, you cannot pass a System.Xml.XmlDocument instance
to the process. The fully qualified name of this XML instance to
pass to the process is InvokePreLoanProcess.PreLoanProcess.XML.
Convert the System.Xml.XmlDocument instance to InvokePreLoanProcess.PreLoanProcess.XML.
You can perform this task by using the following code.
//Create the XML to pass to the FirstAppSolution/PreLoanProcess process
XmlDocument myXML = CreateXML(userName, phone, amount);
//Convert the XML to a InvokePreLoanProcess.PreLoanProcess.XML instance
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
myXML.WriteTo(xw);
InvokePreLoanProcess.PreLoanProcess.XML inXML = new XML();
inXML.document = sw.ToString();
To create an ASP page that invokes the FirstAppSolution/PreLoanProcess process,
perform the following tasks in the Button1_Click method:
Create a FirstAppSolution_PreLoanProcessClient object
by using its default constructor.
Create a FirstAppSolution_PreLoanProcessClient.Endpoint.Address object
by using the System.ServiceModel.EndpointAddress constructor.
Pass a string value that specifies the WSDL to the LiveCycle service and
the encoding type:
http://hiro-xp:8080/soap/services/FirstAppSolution/PreLoanProcess?blob=mtom
You
do not need to use the lc_version attribute. This
attribute is used when you create a service reference. However,
ensure that you specify?blob=mtom.
注意: Replace hiro-xp with the IP address of the J2EE application server hosting LiveCycle.
Create a System.ServiceModel.BasicHttpBinding object
by getting the value of the FirstAppSolution_PreLoanProcessClient.Endpoint.Binding data
member. Cast the return value to BasicHttpBinding.
Set the System.ServiceModel.BasicHttpBinding object’s MessageEncoding data
member to WSMessageEncoding.Mtom. This value ensures
that MTOM is used.
Enable basic HTTP authentication by performing the following
tasks:
Assign the LiveCycle user name to the data
member FirstAppSolution_PreLoanProcessClient.ClientCredentials.UserName.UserName.
Assign the corresponding password value to the data member FirstAppSolution_PreLoanProcessClient.ClientCredentials.UserName.Password.
Assign the constant value HttpClientCredentialType.Basic to the
data member BasicHttpBindingSecurity.Transport.ClientCredentialType.
Assign the constant value BasicHttpSecurityMode.TransportCredentialOnly to
the data member BasicHttpBindingSecurity.Security.Mode.
The
following code example shows these tasks.
//Enable BASIC HTTP authentication
BasicHttpBinding b = (BasicHttpBinding)mortgageClient.Endpoint.Binding;
b.MessageEncoding = WSMessageEncoding.Mtom;
mortgageClient.ClientCredentials.UserName.UserName = "administrator";
mortgageClient.ClientCredentials.UserName.Password = "password";
b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
b.MaxReceivedMessageSize = 2000000;
b.MaxBufferSize = 2000000;
b.ReaderQuotas.MaxArrayLength = 2000000;
Retrieve the name, phone, and amount values that the user
entered into the web page. Use these values to dynamically create
an XML data source that is sent to the FirstAppSolution/PreLoanProcess process.
Create a System.Xml.XmlDocument that represents
the XML data source to pass to the process (this application logic
is shown in the following code example).
Convert the System.Xml.XmlDocument instance
to InvokePreLoanProcess.PreLoanProcess.XML (this
application logic is shown in the following code example).
Invoke the FirstAppSolution/PreLoanProcess process
by invoking the FirstAppSolution_PreLoanProcessClient object’s invoke_Async method.
This method returns a string value that represents the invocation
identifier value of the long-lived process.
Create a JobManagerClient by using is constructor.
(Ensure that you have set a service reference to the Job Manager
service.)
Repeat steps 1-5. Specify the following URL for step 2: http://hiro-xp:8080/soap/services/JobManager?blob=mtom.
Create a JobId object by using its constructor.
Set the JobId object's id data
member with the return value of the FirstAppSolution_PreLoanProcessClient object’s invoke_Async method.
Assign the value true to the JobId object's persistent data
member.
Create a JobStatus object by invoking the JobManagerService object 's getStatus method
and passing the JobId object.
Get the status value by retrieving the value of the JobStatus object's statusCode data
member.
Assign the invocation identifier value to the LabelJobID.Text field.
Assign the status value to the LabelStatus.Text field.