Passing Custom Objects - What am I missing?

Sep 15 2009 9:48 PM

Just learning WCF .. so please be kind...  Developed a server service hosted in windows service, and a vb.net desktop app client. I am having trouble passing a simple .net class back and forth as a parameter.  I'd like to client to create the serviceJob object, load some data into it, pass it to the Post() routine of the Service, have the service manipulate the properties then pass it on to the next (different client) who will do the same. The problem is that when the client instantiates the ServiceJob and sets some properties the receiving service cannot see them, the properties are all set to nothing.  If the server sets properties and returns it to the client, they are visible to the client.  Help.  Code Below.
 
>> THE ServiceJob - The class being passed back and forth
 
<DataContract()>
Public Class ServiceJob

   Private mJobID As String =
"France"
   

   <DataMember()> Public Property JobID() As String
      Get
         Return
mJobID
      End
Get
      Set(ByVal value As String
)
         mJobID = value
      End
Set
   End
Property

End Class
 
>> THE POST() Function on the Server : The Equivilent method on the interface has the <OperationContract> attribute set
 
Public Function Post(ByVal Job As ServiceJob) As String Implements IServiceBus.Post
   Return Job.JobID
End Function

 
>> THE CLIENT Side code
 
   Dim x As New CDI.ServiceBusClient
   Dim Job As New
CDI.ServiceBusClient
   Dim Result as String

   Job.JobID =
"123"
   Result =  X.Post(Job)

   Msgbox(Result) ' IS Nothing

 
>> CONFIG Settings
 
<system.serviceModel>
   <
services
>
      <
service
         name="CDI.ServiceBus
"
         behaviorConfiguration="MyServiceBehavior"
>
         <host
>
            <
baseAddresses
>
               <
add baseAddress="http://localhost:8231/CDI/"
/>
            </
baseAddresses

         </
host
>
         <
endpoint address=
""
            binding="basicHttpBinding
"
            contract="CDI.IServiceBus"
/>
      </
service

   </
services
>

<
behaviors
>
   <
serviceBehaviors
>
      <
behavior name="MyServiceBehavior"
>
      <
serviceMetadata httpGetEnabled="True"
/>
      </
behavior
>
   </
serviceBehaviors
>
</
behaviors
>

</
system.serviceModel>

 
I've trimmed the code to the bare essentials ... ANY help would be appreciated. Thanks!!
 
 
 

Answers (2)