Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Help with Form Data Integration Service API Quickstart using .Net Mtom

Avatar

Level 1

Hello,

Has anyone been able to successfully run the Form Data Integration Service API Quickstart for .Net using Mtom?  I've converted their example to vb.net but every time I run it it returns a message saying "The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error"  I've included my code and xml below.  Can anyone help me out?

Option

Strict On

Imports

System

Imports

System.Collections.Generic

Imports

System.Linq

Imports

System.Text

Imports

System.ServiceModel

Imports

System.IO

'Add a reference to the FormDataIntegration service

Imports

CombineXMLPDF.XMLtoPDF

Partial

Public Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Try

Dim pathOut As String = "C:\Users\brackenk\Desktop\testcombined.xml"

'Create an OutputServiceClient object

Dim svc As New XMLtoPDF.FormDataIntegrationClient()

svc.Endpoint.Address =

New System.ServiceModel.EndpointAddress("http://server.fenetwork.com:8080/soap/services/FormDataIntegration?blob=mtom")

Dim b As BasicHttpBinding = CType(svc.Endpoint.Binding, BasicHttpBinding)

b.MessageEncoding = WSMessageEncoding.Mtom

'Enable BASIC HTTP authentication

svc.ClientCredentials.UserName.UserName =

"name"

svc.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

'Create a BLOB object to store form data

Dim inXMLData As New BLOB()

'Reference XML data

Dim strXMLpath As String = "C:\Users\brackenk\Desktop\loandata.xml"

Dim fsXML As New FileStream(strXMLpath, FileMode.Open)

'Get the length of the file stream and create a byte array

Dim lenXML As Integer = CInt(fsXML.Length)

Dim byteXML(lenXML) As Byte

'Populate the byte array with the contents of the FileStream

fsXML.Read(byteXML, 0, lenXML)

'Populate the BLOB object

'inXMLData.binaryData = byteXML

inXMLData.MTOM = byteXML

'Create a BLOB that represents the input PDF form

Dim inPDFForm As New BLOB()

'Reference the Form data

Dim strPDFPath As String = "C:\Users\brackenk\Desktop\loan.pdf"

Dim fsPDF As New FileStream(strPDFPath, FileMode.Open)

'Get the length of the file stream

Dim lenPDF As Integer = CInt(fsPDF.Length)

Dim bytePDF(lenPDF) As Byte

'Populate the byte array with the contents of the FileStream

fsPDF.Read(bytePDF, 0, lenPDF)

'Populate the BLOB object

'inPDFForm.binaryData = bytePDF

inPDFForm.MTOM = bytePDF

'Import data into the PDF form

Dim result As XMLtoPDF.BLOB

result = svc.importData(inPDFForm, inXMLData)

'Populate the byte array with form data located in the BLOB object

'Dim outByteArray As Byte() = result.binaryData

Dim outByteArray(result.MTOM.Length) As Byte

'Save the form

Dim fsNewPDF As FileStream = New FileStream(pathOut, FileMode.OpenOrCreate)

Dim w As BinaryWriter = New BinaryWriter(fsNewPDF)

w.Write(outByteArray)

w.Close()

fsXML.Close()

fsPDF.Close()

Catch ex As Exception

Response.Write(ex.Message)

End Try

End Sub

End

Class

<?xml version="1.0" encoding="UTF-8" ?>

- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
- <xfa:data>
- <loandata>
- <Layer>
<closeDate>1/26/2007</closeDate>
<lastName>Johnson</lastName>
<firstName>Jerry</firstName>
<mailingAddress>JJohnson@NoMailServer.com</mailingAddress>
<city>New York</city>
<zipCode>00501</zipCode>
<state>NY</state>
<dateBirth>26/08/1973</dateBirth>
<middleInitials>D</middleInitials>
<socialSecurityNumber>(555) 555-5555</socialSecurityNumber>
<phoneNumber>5555550000</phoneNumber>
</Layer>
- <Mortgage>
<mortgageAmount>295000.00</mortgageAmount>
<monthlyMortgagePayment>1724.54</monthlyMortgagePayment>
<purchasePrice>300000</purchasePrice>
<downPayment>5000</downPayment>
<term>25</term>
<interestRate>5.00</interestRate>
</Mortgage>
</loandata>
</xfa:data>
</xfa:datasets>

2 Replies

Avatar

Level 1

Option

Strict On

Imports

System

Imports

System.Collections.Generic

Imports

System.Linq

Imports

System.Text

Imports

System.ServiceModel

Imports

System.IO

'Add a reference to the FormDataIntegration service

Imports

CombineXMLPDF.XMLtoPDF

Partial

Public Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Try

Dim pathOut As String = "C:\Users\brackenk\Desktop\testcombined.xml"

'Create an OutputServiceClient object

Dim svc As New XMLtoPDF.FormDataIntegrationClient()

svc.Endpoint.Address =

New System.ServiceModel.EndpointAddress("http://server.network.com:8080/soap/services/FormDataIntegration?blob=mtom")

Dim b As BasicHttpBinding = CType(svc.Endpoint.Binding, BasicHttpBinding)

b.MessageEncoding = WSMessageEncoding.Mtom

'Enable BASIC HTTP authentication

svc.ClientCredentials.UserName.UserName =

"user"

svc.ClientCredentials.UserName.Password =

"pwd"

b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic

b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly

b.MaxReceivedMessageSize = 2000000

b.MaxBufferSize = 2000000

b.ReaderQuotas.MaxArrayLength = 2000000

'Create a BLOB object to store form data

Dim inXMLData As New BLOB()

'Reference XML data

Dim strXMLpath As String = "C:\Users\brackenk\Desktop\loandata.xml"

Dim fsXML As New FileStream(strXMLpath, FileMode.Open)

'Get the length of the file stream and create a byte array

Dim lenXML As Integer = CInt(fsXML.Length)

Dim byteXML(lenXML) As Byte

'Populate the byte array with the contents of the FileStream

fsXML.Read(byteXML, 0, lenXML)

'Populate the BLOB object

'inXMLData.binaryData = byteXML

inXMLData.MTOM = byteXML

'Create a BLOB that represents the input PDF form

Dim inPDFForm As New BLOB()

'Reference the Form data

Dim strPDFPath As String = "C:\Users\brackenk\Desktop\loan.pdf"

Dim fsPDF As New FileStream(strPDFPath, FileMode.Open)

'Get the length of the file stream

Dim lenPDF As Integer = CInt(fsPDF.Length)

Dim bytePDF(lenPDF) As Byte

'Populate the byte array with the contents of the FileStream

fsPDF.Read(bytePDF, 0, lenPDF)

'Populate the BLOB object

'inPDFForm.binaryData = bytePDF

inPDFForm.MTOM = bytePDF

'Import data into the PDF form

Dim result As XMLtoPDF.BLOB

result = svc.importData(inPDFForm, inXMLData)

'Populate the byte array with form data located in the BLOB object

'Dim outByteArray As Byte() = result.binaryData

Dim outByteArray(result.MTOM.Length) As Byte

'Save the form

Dim fsNewPDF As FileStream = New FileStream(pathOut, FileMode.OpenOrCreate)

Dim w As BinaryWriter = New BinaryWriter(fsNewPDF)

w.Write(outByteArray)

w.Close()

fsXML.Close()

fsPDF.Close()

Catch ex As Exception

Response.Write(ex.Message)

End Try

End Sub

End

Class

Avatar

Level 1
<?xml version="1.0" encoding="UTF-8" ?>
- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
- <xfa:data>
- <loandata>
- <Layer>
<closeDate>1/26/2007</closeDate>
<lastName>Johnson</lastName>
<firstName>Jerry</firstName>
<mailingAddress>JJohnson@NoMailServer.com</mailingAddress>
<city>New York</city>
<zipCode>00501</zipCode>
<state>NY</state>
<dateBirth>26/08/1973</dateBirth>
<middleInitials>D</middleInitials>
<socialSecurityNumber>(555) 555-5555</socialSecurityNumber>
<phoneNumber>5555550000</phoneNumber>
</Layer>
- <Mortgage>
<mortgageAmount>295000.00</mortgageAmount>
<monthlyMortgagePayment>1724.54</monthlyMortgagePayment>
<purchasePrice>300000</purchasePrice>
<downPayment>5000</downPayment>
<term>25</term>
<interestRate>5.00</interestRate>
</Mortgage>
</loandata>
</xfa:data>
</xfa:datasets>