作为 ASMX 公开的 WCF 服务不接受参数

发布于 2024-09-07 23:24:31 字数 766 浏览 0 评论 0原文

我有一个在 Delphi 2006 中开发的服务器/客户端应用程序。客户端是 Win32,服务器是 .net 1.1 Web 服务。

我们正在更新这个项目,但必须分步完成。我从服务器开始,在 VS2010(C# .net 4.0) 中创建了一个 WCF 项目。第一步是在不更改客户端的情况下让服务器在 WCF 中运行。所以我使用了外观模式,创建了一个与旧的delphi Webservice类似的接口,添加了对旧的.net 1.1 dll的引用,并且在我的实现中我只是调用了旧的.net 1.1代码。

下一步更新客户端上的代理类。这失败了。 WSDL 导入器无法正确理解 basicHttpBinding,因此生成的代理类无法替换现有代理。

经过一番研究后,我发现了这篇博文。

http://kjellsj。 blogspot.com/2006/12/how-to-expose-wcf-service-also-as-asmx.html

这有效,ASMX WSDL 与旧的 .net 1.1 没有什么不同,所以一切都正常。

但事实并非如此。在测试新服务时,我发现服务器上的所有参数都是空白/空。我尝试在客户端上使用 Fiddler,参数存在于发送到服务器的 XML 中。

所以我被困住了。任何有关如何解决此问题的想法将不胜感激。有没有任何有趣的代码可以让我知道。

I have a server/client application developed in Delphi 2006. The client is Win32 and the Server is a .net 1.1 webservice.

We are in the process of updateing this project, but it has to be done in small steps. I started with the server and created a WCF project in VS2010(C# .net 4.0). The first step is to get the server running in WCF without changing the client. So I used the facade pattern, created a similar interface to the old delphi Webservice added a reference to the old .net 1.1 dll and in my implementation I just called the old .net 1.1 code.

Next step updating the proxy class on the client. This failed. The WSDL importer didn't understand the basicHttpBinding correctly, so the proxy class that was genereated couldn't replace the existing proxy.

After a bit of research I found this blog post.

http://kjellsj.blogspot.com/2006/12/how-to-expose-wcf-service-also-as-asmx.html

This worked, the ASMX WSDL was no different than the old .net 1.1 so everything appered ok.

But it wasn't. When testing the new service I discovered that all my parameters was blank/null on the server. I tried with Fiddler on the client and the parameters is present in the XML that is sent to the server.

So I'm stuck. Any thoughts on how to solve this would be much appreciated. Is there any code that could be interresting to see then let me know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

末骤雨初歇 2024-09-14 23:24:31

我在 Web 服务 asmx 中遇到了类似的问题...某些数据正在丢失其值。如果您使用分层数据,则可能需要使用 XmlInclude 属性来声明内部或继承的对象。例如,如果您有一个在服务中使用的 User 类和一个 Customer 子类,则如果不直接在 Web 方法中使用它,您可能需要向服务声明 Customer 类。您将按如下方式执行此操作。

[XmlInclude(typeof(Customer))]
public class Service : WebService

当然,也可能与此无关,如果是这样的话,祝你好运。 :)

I ran into a similar problem with a web service asmx... certain data was losing their values. If you are using hierarchical data, you may need to declare the internal or inherited objects using an XmlInclude attribute. For example, if you have a User class that is used in your service and a Customer sub class, you may need to declare the Customer class to the service if it is not used directly in a web method. You would do this as follows.

[XmlInclude(typeof(Customer))]
public class Service : WebService

Of course, it may be nothing to do with this, so good luck if that's the case. :)

花心好男孩 2024-09-14 23:24:31

确认新服务中的参数名称与旧服务中的名称匹配。如果您更改了参数名称,它们将不会从 XML 映射,因此在执行代码中将为 null。

Confirm that the parameter names in the new service match the names in the old service. If you have changed the parameter names, they will not map from the XML so will be null in the executing code.

又怨 2024-09-14 23:24:31

向子类添加 KnownType 属性

Add KnownType attribute to the sub classes

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