ASMX Web引用未更新服务返回类型已更新(ASMX Web Reference not Updating After Service Return Type Updated)

我有一个名为MyCompany.WebService1的Web服务

我在我的ASP.net Web应用程序中使用Web引用来引用它。

Theres在这个Web服务中称为“GetDeal”,返回一个“Deal”对象。 交易对象目前看起来(例如)像这样:

public class Deal { Public string Name {get;set;} Public string Description {get;set;} }

这个类在不同的程序集中:MyCompany.Model

Web服务引用此程序集。

在我的网络应用程序中,我可以调用GetDeal方法。 这将返回Service1.Deal(service1只是Web引用的名称)

我可以访问上面的两个属性。

我现在改变了Deal类,并添加了更多的属性。 但是,我无法在我的Web应用程序中看到这些新属性。

我已经在Web应用程序中更新了Web服务。 我重建了几次Web服务,尝试删除MyCompany.Model引用并重新添加它等等...

我无法弄清楚发生了什么变化......这是行得通的 - 我之前改变了模型,并且正确地更新了参考...

我错过了什么?

I have a webservice - called MyCompany.WebService1

I reference this using a web reference in my ASP.net web application.

Theres a method called "GetDeal" in this web service, that returns a "Deal" Object. The deal object currently looks (for example) like this:

public class Deal { Public string Name {get;set;} Public string Description {get;set;} }

This class is in a different assembly: MyCompany.Model

The web service references this assembly.

In my web app, I can call the GetDeal method. This returns Service1.Deal (service1 is just the name of the web reference)

I can access both properties above.

I have now changed the Deal class, and added a couple more properties. However, I can't see these new properties in my web application.

I've updated the web service in the web application. I rebuilt the web service several times, tried removing the MyCompany.Model reference and re-addding it etc...

I can't figure out what has changed... This was working - I have changed the model before, and it's updated the reference correctly...

Anything I've missed?

最满意答案

只要满足以下几点,这应该起作用:

新属性标记为Public并且必须是读/写的(必须有getter和setter) 您已编译主机Web应用程序(公开Web服务的Web应用程序)。 (您可以尝试在Web浏览器中调用Web服务以检查新属性是否可见)。 您已更新Web引用客户端应用程序(并重建了应用程序)

As long as the following points are fulfilled, this should work:

the new property is marked as Public and must be read/write (must have a getter and a setter) you have compiled the host web application (the web app which exposes the web service). (You can try calling the web service in a web browser to check whether the new property is visible). you have updated the web reference the client application (and rebuilt the app)

更多推荐