将自定义对象传递给 Windows 工作流 WCF 服务

发布于 2024-08-16 02:57:59 字数 887 浏览 4 评论 0原文

由于某种原因,我在传递对象时遇到问题,我不确定为什么。我收到“对象引用未设置为对象实例”错误。

基本上,我从我的客户端应用程序调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖公主 2024-08-23 02:57:59

我自己也遇到过这个问题,就我而言,这是自定义对象上的序列化错误。为了能够通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文