Quantcast
Channel: SCN : All Content - PowerBuilder Developer Center
Viewing all articles
Browse latest Browse all 2935

Trying to pass a large byte array to a web service from PowerBuilder Classic 12.5

$
0
0

Has anyone had any luck passing large byte arrays to a web service from PowerBuilder Classic 12.5?

 

I have created a web service that is running on an IIS server. 
I call this web service from PowerBuilder Classic 12.5.
This web service is used to store and retrieve PDF files from an imaging system.

I have tried using PowerBuilder .NET to create the Client Proxy but ran into an issue of PB.Net randomly not being able to find part of the object returned by the web service.

My latest attempt is to write the Client Proxy in VB.NET and it works except I am unable to pass the bytes from any PDFs over 16384 in size because I am getting a "The maximum array length quota (16384) has been exceeded while reading XML data." error.

I am setting the myBinding.ReaderQuotas.MaxArrayLength to Int32.MaxValue and still get the error.

It looks like the COM object is overriding any changes that I make to the MaxArrayLength.

 

I have include an example of my code so far:

 

'VB.NET code (with ChartProxyClass Project Properties -> Compile -> Register for COM interop checkbox checked)
Imports System
Imports System.ServiceModel

<ComClass(ChartsProxyClass1.ClassId, ChartsProxyClass1.InterfaceId, ChartsProxyClass1.EventsId)>
Public Class ChartsProxyClass1
    Public Const ClassId As String = "63926C42-E702-4747-8A12-1ED9D345C098"
    Public Const InterfaceId As String = "35778944-B43D-4A19-A8CF-992373219616"
    Public Const EventsId As String = "8B798D1E-6A24-4679-B22C-E49A23EA9E32"

 

    Public Sub New()
        MyBase.New()
    End Sub


    <ServiceContract()>
    Public Interface IChartsWebService

        <OperationContract()>
        Function SaveImage(ByVal image As Byte()) As ServiceReference1.UploadImageResult

    End Interface

 

    Public Function of_Uploadimage(ByVal image As Byte(), ByRef statusCode As Long, ByRef errorMessage As String) As Long
        Dim myBinding As New BasicHttpBinding
        myBinding.ReaderQuotas.MaxArrayLength = Int32.MaxValue

        Dim myEndpoint As New EndpointAddress("http://myWebServer/ChartsWebservice/Service1.svc")
        Dim myChannelFactory As ChannelFactory(Of IChartsWebService) _
            = New ChannelFactory(Of IChartsWebService)(myBinding, myEndpoint)
        Dim client As IChartsWebService = myChannelFactory.CreateChannel()
        Dim docHandle As Long
        Dim rm As ServiceReference1.UploadImageResult

        Try
            rm = client.SaveImage(image)
            statusCode = rm.StatusCode
            errorMessage = rm.ErrorMessage
            docHandle = rm.DocHandle
        Catch e As Exception
            statusCode = -1
            errorMessage = e.Message
            docHandle = -1
        End Try

        myChannelFactory.Close()

        Return docHandle

    End Function

End Class


// PowerBuilder code
public function long of_save_image (string as_cache_filename);
   Integer li_filehandle
   blob lblb_file_blob
   Long ll_StatusCode = 0, ll_DocHandle = 0
   String ls_ErrorMessage = ""
   Long ll_return
   oleobject l_proxywrapper
   byte lb_ImageBytes[]

   li_filehandle = FileOpen(as_cache_filename, StreamMode!)
   FileReadEx(li_filehandle, lblb_file_blob)
   FileClose(li_filehandle)

   l_proxywrapper = CREATE oleobject
   ll_return = l_proxywrapper.ConnectToNewObject("ChartProxyClass.ChartsProxyClass1")

   // Pass the bytes from the file to the web service
   lb_ImageBytes = GetByteArray(lblb_file_blob)
   ll_DocHandle = l_proxywrapper.of_uploadimage(lb_ImageBytes, REF ll_StatusCode, REF ls_ErrorMessage)

   RETURN ll_DocHandle

end function


Viewing all articles
Browse latest Browse all 2935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>