views:

111

answers:

1

Hello, I'm having a problem passing an object for some reason and I'm not sure why. I'm getting a Object reference not set to an instance of an object error.

Essentially from my client application I make a call to a Windows Work...

Client Code

Workflow1Client client = new Workflow1Client();
ACME.Order newOrder = new ACME.Order();

newOrder.Property1 = "xyz";
//set all the other properties

string status = client.GetData(newOrder);  
//**This is where object reference error occurs**

Proxy Expecting

public string GetData(ACME.Order NewOrder)
{
     return base.Channel.GetData(NewOrder);
}

Workflow Code

[ServiceContract]
public interface IWorkflow1
        {
                [OperationContract]
        string GetData(ACME.Order NewOrder);
        // TODO: Add your service operations here
    }

I'd appreciate any help on this. Also beyond this question is sending a Object (ACME.Order) good practice or should I be trying to tackle this a different way?

Thanks

A: 

I have run into this myself and in my case it was a Serialization error on the custom object. To be able to send a custom object across WCF it should have the [Serializable] attribute. To test, see if you can serialize the object to an XML file. If that fails the WCF transfer will not work.

Hope that helps.

Jerb
Thanks Jerb I was able to get this working. It was related to the ServiceOperationInfo on my workflow.
Kuruption
You could also use the [DataContract] attribute on your data classes, and also append [DataMember] attributes to the properties on the data class you want to include in the serialization. That provides more fine-grain control on what gets serialized.
arabian tiger