开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜