0

I have written a WCF service using vb. The client, written by a third party in c# requires two out parameters.

The service works correctly, but I have a problem with the out parameters.

Searching SO I found the solution and I have been able to declare the two parameters using the prefix.

One of the parameters is a string and the other is an array of objects as shown by the declaration below.

Function getStatusAndCosts(<Out()> ByRef commStatus() As communicationStatus, <Out()> ByRef communicationError As String, ByVal strUser As String, ByVal strPwd As String, ByVal communicationId As Guid) As Boolean

When I launch the client, the array returns empty, while the string is filled with the correct data.

    Dim bTest As Boolean = False
    Dim strTest As String ="-"
    Dim tmpcommListArray() As DocPos_WebService.IDocPoscommunicationStatus
    Dim tmpGuid As New Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
    bTest = client.getStatusAndCosts(tmpcommListArray, strTest, "yyy", "yyy", tmpGuid)

I tried to remove the second out parameter (see the declaration below)

Function getStatusAndCosts(<Out()> ByRef commStatus() As communicationStatus, ByVal strUser As String, ByVal strPwd As String, ByVal communicationId As Guid) As Boolean

In this case the array is filled with the correct data.

I tried also to change the order of the parameters with no result (the string is filled the array returns empty)

Where do I am wrong? Is it possible to have multiple out params in vb?

Thanks for your replies!

  • 2
    If you're returning so much data, why not bite the bullet and create a proper class and return it? – DavidG Oct 14 '14 at 08:11
  • Assuming you really cannot change the third party library (invalidating the preferred approach suggested by DavidG): Did you check if the communicationStatus (lower case class?) is correctly serialized by the server? "Object" is never correctly serialized. Out parameters are only supported in WCF in some very specific configurations. see http://stackoverflow.com/questions/4630627/wcf-operations-with-out-parameters-are-not-supported – realbart Oct 14 '14 at 08:16

0 Answers0