将自定义对象传递给 Windows 工作流 WCF 服务
由于某种原因,我在传递对象时遇到问题,我不确定为什么。我收到“对象引用未设置为对象实例”错误。
基本上,我从我的客户端应用程序调用 Windows Work...
客户端代码
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**
代理期望
public string GetData(ACME.Order NewOrder)
{
return base.Channel.GetData(NewOrder);
}
工作流程代码
[ServiceContract]
public interface IWorkflow1
{
[OperationContract]
string GetData(ACME.Order NewOrder);
// TODO: Add your service operations here
}
如果有任何帮助,我将不胜感激这。除了这个问题之外,发送对象(ACME.Order)也是一种好的做法,还是我应该尝试以不同的方式解决这个问题?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己也遇到过这个问题,就我而言,这是自定义对象上的序列化错误。为了能够通过 WCF 发送自定义对象,它应该具有 [Serializable] 属性。要进行测试,请查看是否可以将该对象序列化为 XML 文件。如果失败,WCF 传输将无法工作。
希望有帮助。
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.