简体   繁体   中英

Passing a custom object to a Windows Workflow WCF Service

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM