[英]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... 从本质上来说,我是从客户端应用程序调用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? 除了这个问题之外,还发送对象(ACME.Order)的良好做法还是我应该尝试以其他方式解决这个问题?
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. 为了能够跨WCF发送自定义对象,它应该具有[Serializable]属性。 To test, see if you can serialize the object to an XML file. 要测试,请查看是否可以将对象序列化为XML文件。 If that fails the WCF transfer will not work. 如果失败,则WCF传输将无法进行。
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.