Dim i As Int32 Dim i As Int32 对于i = 0到componentProduct.Count - 1 myCost = myCost + componentProduct.Item(i).ProductCost 下一页返回myCost 结束函数 Public Sub AddProduct(ByVal inputProduct As Product)如果inputProduct.GetType是GetType(Product)那么 componentProduct.Add(inputProduct)否则抛出新的ArgumentException(inputProduct必须是产品类型。,inputProduct)结束如果 End Sub Public Sub AddProperty(ByVal inputProperty As Properties) PropertyList.Add(inputProperty) End Sub 结束类如你所见,我有两种方法该课程让我添加一些电话产品属性和组件产品进入产品对象。并且具有ArrayList" PropertyList"和componentProduct存储这些对象 在我的VB.NET客户端界面中,添加webreference后,我只是意识到我可以声明一个WebService的类对象的实例在我的客户端界面中如下: 假设我的Web Ref命名为ProjectInit代码: Dim myProduct As New ProjectInit.Product 现在我们去问题!!当我尝试在客户端界面中声明一些webservice的Product对象并尝试在Product类中调用AddProduct方法时,它没有在中显示Intellsense菜单我甚至无法调用ArrayList的Add方法来将我的产品对象添加到其中。 我原来的想法是创建并初始化 webservice类对象,包含所有它的组件属性和产品,然后我可以将这个产品对象抛到我的webservice 并让webservice用它做任何想做的事。 是不是你不能在类/类型中调用WebService的方法(如果我的客户端接口只是Web引用它)?我希望我只是做错了所以它会导致问题。但如果情况并非如此,那么有什么工作要做? 提前致谢。 Make the story short, I have a VB.NET client interface calling .NET webservice, written in VB.NET as well. I am trying to make the client as thin as possible so I let the webservice part to handle most of the things. Currently I have a class called "Product" sitting my webserivce like the following: Code: Imports System.Xml.Serialization <XmlInclude(GetType(Properties)), XmlInclude(GetType(Product))> Public Class Product '' Product properties Public masterQty As Int32 Public cost As Double '' temperary cost, will use config costs to replace Public PropertyList As New ArrayList '' ArrayList stores it''s component product Public optionCondition As Int16 '' 1 = OR, 2 = AND Public componentProduct As New ArrayList Public Function ProductCost() As Double Dim myCost As Double myCost = Me.cost '' Get cost in the product ArrayList Dim i As Int32 For i = 0 To componentProduct.Count - 1 myCost = myCost + componentProduct.Item(i).ProductCost Next Return myCost End Function Public Sub AddProduct(ByVal inputProduct As Product) If inputProduct.GetType Is GetType(Product) Then componentProduct.Add(inputProduct) Else Throw New ArgumentException("inputProduct must be of type Product.", "inputProduct") End If End Sub Public Sub AddProperty(ByVal inputProperty As Properties) PropertyList.Add(inputProperty) End Sub End Class As you can see I have 2 methods in the class let me add something call "Product Property" and "Component Product" into the "Product" object. And having ArrayList "PropertyList" and "componentProduct" to store those objects In my VB.NET Client interface, after I add the webreference, I just realised I can declare an instance of the WebService''s classes object in my client interface like the following: Assuming my Web Ref named "ProjectInit" Code: Dim myProduct As New ProjectInit.Product Now here we go the PROBLEM!! When I try to declare a few more webservice''s Product object in my client side interface and try to call the AddProduct methods in the Product class, it doesn''t show in the Intellsense menu I can''t even call the ArrayList''s Add method to add my product object into it. My original thought is to create and initialize an instance of the webservice class object, with all it''s component properties and products, then I can just throw this product object to my webservice and let the webservice to do whatever it wants with it. Is it that you cannot call a WebService''s method in a Class/Type (if my Client side interface just Web Referenced it)? I wish I just doing something wrong so it cause the problem. But If it''s not the case, what is the work around? Thanks in advance. Andy, 每次在 客户端解决方案中添加时,你都刷过了webclass吗? Cor " Andy" < po ******** @ yahoo.com.hk>Andy,You did refresh the webclass everytime that you made additions in yourclient solution?Cor"Andy" <po********@yahoo.com.hk>这就是我现在拥有的网络方法。 我的网络服务部分和我的用户界面部分都不完整。我向你展示的网络方法,没有完成(这就是为什么我没有发布它)。它假设要做的是通过将Project对象添加到Project中来初始化Project 对象,并在Project内部稍微围绕Product对象。 我现在非常关心是:如果我可以从我的客户端UI调用我的产品类中的方法。 < WebMethod()> Public Function ProjectInitial(ByVal inputProduct as Project)作为项目''用于项目初始化的Web方法,输入的产品对象我的项目作为新项目昏暗 myProject = InitialProject(inputProduct) 返回myProject 结束函数 Cor Ligthert <无************ @ planet.nl>在消息中写道新闻:< eF ************** @ TK2MSFTNGP12.phx.gbl> ... That''s the webmethod I have currently have now. Both my webservice part and my user interface part is not complete. The webmethod I showed you, which is not completed (that''s why I didn''t posted it out). What it suppose to do is initialize the Project object by adding Product object into the Project and jigging around the Product object a little inside the Project. All I really care now is: If I can call the methods I have in my Product class from my client side UI. <WebMethod()> Public Function ProjectInitial(ByVal inputProduct as Project) As Project '' Webmethod for Project Initialization with inputted Product object Dim myProject As New Project myProject = InitialProject(inputProduct) Return myProject End Function "Cor Ligthert" <no************@planet.nl> wrote in message news:<eF**************@TK2MSFTNGP12.phx.gbl>... Andy, 我想念这个的原因是什么?< WebMethod()> _ Cory /> 安迪 < po ******** @ yahoo.com.hk> Andy, Any reason why I miss this? <WebMethod()> _ Cor "Andy" <po********@yahoo.com.hk>>简而言之,我有一个名为.NET的VB.NET客户端界面> webservice,也是用VB.NET编写的。> >我试图让客户尽可能地薄,所以我让> webservice部分处理大部分事情。> >目前我有一个叫做产品的课程。坐在我的webserivce就像>以下内容:> >代码:> Imports System.Xml.Serialization > > < XmlInclude(GetType(Properties)),XmlInclude(GetType(Product))>公众>类产品> ''产品属性> Public masterQty As Int32 >公共成本As Double''的成本,将使用配置成本>替换> Public PropertyList As New ArrayList > > ''ArrayList存储它的组件产品> Public optionCondition As Int16''1 = OR,2 = AND >公共componentProduct As New ArrayList > > Public Function ProductCost()As Double > Dim myCost As Double > myCost = Me.cost > > ''在产品中获得成本ArrayList > Dim i As Int32 >对于i = 0到componentProduct.Count - 1 > myCost = myCost + componentProduct.Item(i).ProductCost >下一页>返回myCost >结束功能> > Public Sub AddProduct(ByVal inputProduct As Product)>如果inputProduct.GetType是GetType(Product)那么> componentProduct.Add(inputProduct)>否则>抛出新的ArgumentException(inputProduct必须是> Product。,inputProduct)>结束如果>结束子> > Public Sub AddProperty(ByVal inputProperty As Properties)> PropertyList.Add(inputProperty)>结束子> >最终课程>正如你所看到的,我在课堂上有2个方法让我添加一些调用> 产品属性和组件产品进入产品对象。>并且具有ArrayList" PropertyList"和componentProduct存储>那些物品> >在我的VB.NET客户端界面中,添加webreference后,我只是>意识到我可以声明一个WebService的类对象的实例>在我的客户端界面中,如下所示:> >假设我的Web Ref命名为ProjectInit>代码:> Dim myProduct As New ProjectInit.Product >现在我们去问题!!当我试图宣布更多的> webservice在我的客户端界面中的Product对象并尝试>在Product类中调用AddProduct方法,它不会显示在>中。 Intellsense菜单我甚至不能将ArrayList的Add方法称为>将我的产品对象添加到其中。> >我最初的想法是创建并初始化>的实例。 webservice类对象,包含它的所有组件属性和>产品,然后我可以把这个产品对象扔到我的webservice >让网络服务用它做任何想做的事。> >是不是你不能在类/类型中调用WebService的方法(如果>我的客户端接口只是Web引用它)?我希望我只是做>出错了所以导致问题。但如果情况并非如此,>工作是什么?> >在此先感谢。 > Make the story short, I have a VB.NET client interface calling .NET > webservice, written in VB.NET as well. > > I am trying to make the client as thin as possible so I let the > webservice part to handle most of the things. > > Currently I have a class called "Product" sitting my webserivce like > the following: > > Code: > Imports System.Xml.Serialization > > <XmlInclude(GetType(Properties)), XmlInclude(GetType(Product))> Public > Class Product > '' Product properties > Public masterQty As Int32 > Public cost As Double '' temperary cost, will use config costs to > replace > Public PropertyList As New ArrayList > > '' ArrayList stores it''s component product > Public optionCondition As Int16 '' 1 = OR, 2 = AND > Public componentProduct As New ArrayList > > Public Function ProductCost() As Double > Dim myCost As Double > myCost = Me.cost > > '' Get cost in the product ArrayList > Dim i As Int32 > For i = 0 To componentProduct.Count - 1 > myCost = myCost + componentProduct.Item(i).ProductCost > Next > Return myCost > End Function > > Public Sub AddProduct(ByVal inputProduct As Product) > If inputProduct.GetType Is GetType(Product) Then > componentProduct.Add(inputProduct) > Else > Throw New ArgumentException("inputProduct must be of type > Product.", "inputProduct") > End If > End Sub > > Public Sub AddProperty(ByVal inputProperty As Properties) > PropertyList.Add(inputProperty) > End Sub > > End Class > As you can see I have 2 methods in the class let me add something call > "Product Property" and "Component Product" into the "Product" object. > And having ArrayList "PropertyList" and "componentProduct" to store > those objects > > In my VB.NET Client interface, after I add the webreference, I just > realised I can declare an instance of the WebService''s classes object > in my client interface like the following: > > Assuming my Web Ref named "ProjectInit" > Code: > Dim myProduct As New ProjectInit.Product > Now here we go the PROBLEM!! When I try to declare a few more > webservice''s Product object in my client side interface and try to > call the AddProduct methods in the Product class, it doesn''t show in > the Intellsense menu I can''t even call the ArrayList''s Add method to > add my product object into it. > > My original thought is to create and initialize an instance of the > webservice class object, with all it''s component properties and > products, then I can just throw this product object to my webservice > and let the webservice to do whatever it wants with it. > > Is it that you cannot call a WebService''s method in a Class/Type (if > my Client side interface just Web Referenced it)? I wish I just doing > something wrong so it cause the problem. But If it''s not the case, > what is the work around? > > Thanks in advance. 这篇关于可以从VB.NET客户端界面访问webservice类的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 05:04